火狐获取文件路径为undefined,求助!!

melonlds 2017-07-16 12:13:25
以下是我的jsp页面代码,请大神们帮忙看看!

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="common.constants.WebConstants" %>
<%@page import="ag.o"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String contextPath=WebConstants.GLOBAL_WEB_ROOT;

%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>信息导入</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<link href="<%=request.getContextPath()%>/resources/skfpgl/css.css" type="text/css" rel="stylesheet">
<link href="<%=request.getContextPath()%>/resources/common/css/bluetbl.css" type="text/css" rel="stylesheet">
<script type="text/javascript" src="<%=path %>/resources/common/jquery/jquery-1.3.2.min.js"></script>
<script type="text/javascript">

var skfp;
var jwtzxx;
var i = 0;
var xh;
var json;
$(function(){
//导入文件的时候加载文件
$("#dr").click(function(){
var filePath = getPath($("#drFile"));//这里出错,提示是undefined
//ajax 的方式提交
if(filePath != ""){
$("#jwtzxx tr:gt(0)").remove();
$("#drForm").submit();
//alert(filePath);
}
else{
alert("请选择需要上传的文件!");
}
return ;
});

//提交保存
$("#submit").click(function(){
if(confirm("确认提交失控发票数据吗?")){
location.href = "<%=path%>/skfpgl/skfpdr.do?method=submit";
}else{
return ;
}
});

//文件下载
$("#downFile").click(function(){
location.href = "<%=path%>/skfpgl/skfpdr.do?method=downFile";
});
});

//获取上传文件的全路径
function getPath(obj) {
if (obj) {
if (window.navigator.userAgent.indexOf("MSIE") > -1) {
obj.select();
return document.selection.createRange().text;
}
else if (window.navigator.userAgent.indexOf("Firefox") > -1) {
if (obj.files) { //发现这里提示也是undefined
return obj.files.item(0).getAsDataURL();
}
return obj.value;
}
return obj.value;
}
}
</script>
</head>
<body>
<fieldset style="width:1000;position:relative">
<legend id="lgd1" style="position:relative;left:3%;cursor:pointer">
文件导入
</legend>
<br/>
<DIV id="sstj">
<form action="<%=path%>/skfpgl/skfpdr.do?method=importSkfp" method="post" id="drForm" name="drForm" enctype="multipart/form-data">
<table width="1000" class="public_table">
<TR>
<td class="public_lable public_center public_bold" width="160" onclick="b_onclick()">导入文件</td>
<td class="public_padding" width="340" >
<input type="file" name="drFile" size="45" style="font-size:13px" id="drFile"/>
</td>
<td class="public_padding" width="340" >
      
<input type="button" id="dr" value="导入" size="45" style="font-size:13px">
</td>
<td class="public_padding" width="340" >
 
<input type="button" id="submit" value="提交数据" id="y" isabled="disabled">
</td>
<td class="public_padding" width="340" >
<input type="button" id="downFile" value="下载导入文件模版">
</td>
</TR>
</table>

</form>
<br/>
</DIV>
</fieldset>
<br>
<br><br>
</body>
</html>
...全文
290 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
melonlds 2017-07-22
  • 打赏
  • 举报
回复
顶起。。。。。。。。
墨笙弘一 2017-07-22
  • 打赏
  • 举报
回复
打断点 看流程 然后看看那个写的对不对 obj是什么

50,523

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧