84669 personnes étudient
152542 personnes étudient
20005 personnes étudient
5487 personnes étudient
7821 personnes étudient
359900 personnes étudient
3350 personnes étudient
180660 personnes étudient
48569 personnes étudient
18603 personnes étudient
40936 personnes étudient
1549 personnes étudient
1183 personnes étudient
32909 personnes étudient
用chrome上传图片,在浏览器的开发者模式中,看到图片地址被改成file:\c:\fakepathxxx.jpg了,网上搜了很多,都说的很模糊,而且没能解决这个问题,哪位大神帮忙解决一下,拜谢!
欢迎选择我的课程,让我们一起见证您的进步~~
自己倒腾了半天,终于解决了,并在chrome浏览器上验证可行,方法如下:function getImgURL(node) {
var imgURL = ""; try{ var file = null; if(node.files && node.files[0] ){ file = node.files[0]; }else if(node.files && node.files.item(0)) { file = node.files.item(0); } //Firefox 因安全性问题已无法直接通过input[file].value 获取完整的文件路径 try{ //Firefox7.0 imgURL = file.getAsDataURL(); //alert("//Firefox7.0"+imgRUL); }catch(e){ //Firefox8.0以上 imgURL = window.URL.createObjectURL(file); //alert("//Firefox8.0以上"+imgRUL); } }catch(e){ //这里不知道怎么处理了,如果是遨游的话会报这个异常 //支持html5的浏览器,比如高版本的firefox、chrome、ie10 if (node.files && node.files[0]) { var reader = new FileReader(); reader.onload = function (e) { imgURL = e.target.result; }; reader.readAsDataURL(node.files[0]); } } return imgURL; }
注意在传递node的时候要传递document.getElementById 获取的节点,不要用jquery的方式去获取节点
感动到哭,谢谢你!
获取出来的值是加了密的啊 我上传要使用的地址要怎么解析 blob:http:localhost:808077b295b4-a8b0-40f2-8523-63446f5fedfd (文件名、目录名或卷标语法不正确。) 这是通过此方法获取的文件路径,我只是要某个盘符下的某个具体文件
自己倒腾了半天,终于解决了,并在chrome浏览器上验证可行,方法如下:
function getImgURL(node) {
注意在传递node的时候要传递document.getElementById 获取的节点,不要用jquery的方式去获取节点
感动到哭,谢谢你!
获取出来的值是加了密的啊 我上传要使用的地址要怎么解析 blob:http:localhost:808077b295b4-a8b0-40f2-8523-63446f5fedfd (文件名、目录名或卷标语法不正确。) 这是通过此方法获取的文件路径,我只是要某个盘符下的某个具体文件