jquery中获取<input type=file id='fileid'>路径问题,ie和火狐有区别,在火狐中我怎么获取其路径,ie可以

jquery中获取<input type=file id='fileid'>路径问题,ie和火狐有区别,在火狐中我怎么获取其路径,ie可以,第1张

IE与FF获取上传文件路径方法

1 function getPath(obj)

2 {

3 if(obj)

4 {

5

6 if (windownavigatoruserAgentindexOf("MSIE")>=1)

7 {

8 objselect();

9

10 return documentselectioncreateRange()text;

11 }

12

13 else if(windownavigatoruserAgentindexOf("Firefox")>=1)

14 {

15 if(objfiles)

16 {

17

18 return objfilesitem(0)getAsDataURL();

19 }

20 return objvalue;

21 }

22 return objvalue;

23 }

24 }

1首先是jsp

<button class="btn button uploadAndNext" id="importWhiteBtn" type="button">

<span class="button">提交导入</span>

</button>

2然后是js

$(function(){

var uploadCom = null;

function uploadIt() {

$("#importWhiteBtn")click(function() {

var uploadId = "#" + $(this)attr("id");

var btn = $(this);

uploadCom = new AjaxUpload( uploadId + "" , {

action : "whitePhoneNumberdoaction=importFile",

onSubmit: function(file, ext) {

if ((ext && /^(txt)$/test(ext))) {

alert("请先下载导入模板readmetxt参考,您上传的文档格式不对,请重新选择!");

return false;

}

$blockUI({

message:"正在上传到服务器"

})

},

onComplete: function(file, response) {

$unblockUI();

if(response=="success"){

alert( "导入成功");

$('#whitePhoneList')flexReload();

}else{

alert( "导入失败,"+response);

}

}

});

});

$("uploadAndNext")click();

}

uploadIt();

firstClick = false;

})

3最后是action

public ActionForward importFile(ActionMapping mapping, ActionForm form,

>

给题主几个关键字:

HTML5,FileReader,FileList,readAsText

Jquery跟读取本地文本文件没有一点关系,jquery没这个功能,能做到的只有HTML5的fileReader(当然你要说IE的话当我没说)。使用的时候考虑下兼容性。

ps最后再吐槽下题主的问题,如果你悬赏了很高的分数,我就不说啥了。关键是一分没有,没弄清楚问题,还“回答之前先调试”,别这么高傲好吧,别人给你思路就已经足够你解决问题了。

var files = $("file-box")find("input[type='file']");

fileseach(function(){

alert($(this)val());

});

试试

方法如下:

<input id='myinputid' class='myinputclass' type='text' value='123'/>

var value = $('#myinputid')val();//通过ID获得

var value = $('myinputclass')val();//通过类名获得

$('input')on('change',function(){

var value = $(this)val();

value = valuesplit("\\")[2];

})

value 就是名称。因为浏览器安全机制 获取到的value都是C:\fakepath\  加上名,所以可以用这个方式获取

语法Input(number, [#]filenumber)Input 函数的语法具有以下几个部分:部分描述number必要。任何有效的数值表达式,指定要返回的字符个数。filenumber必要。

任何有效的文件号。说明通常用 Print # 或 Put 将 Input 函数读出的数据写入文件。Input 函数只用于以 Input 或 Binary 方式打开的文件。

与 Input # 语句不同,Input 函数返回它所读出的所有字符,包括逗号、回车符、空白列、换行符、引号和前导空格等。

对于 Binary 访问类型打开的文件,如果试图用 Input 函数读出整个文件,则会在 EOF 返回 True 时产生错误。

<span id="myItem">选项卡</span>

<a id="myContent">这里是要显示在选项卡的内容</a>

js:

jQuery("#myContent")click(function(){

var myContent = jQuery("#myContent")val();

//把a标签的内容显示在选项卡中

jQuery("#myItem")html(myContent) ;

//把a标签的内容显示在选项卡的title属性中

jQuery("#myItem")attr("title",myContent) ;

});

以上就是关于jquery中获取<input type=file id='fileid'>路径问题,ie和火狐有区别,在火狐中我怎么获取其路径,ie可以全部的内容,包括:jquery中获取<input type=file id='fileid'>路径问题,ie和火狐有区别,在火狐中我怎么获取其路径,ie可以、jquery 获取fileupload的完整路径。给完整的代码。直接可以用的、用jquery 读取文件域中的文件并读取等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/9685229.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-30
下一篇2023-04-30

发表评论

登录后才能评论

评论列表(0条)

    保存