Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/365.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript IE-9在使用输入类型文件时给出伪路径_Javascript_Internet Explorer 9 - Fatal编程技术网

Javascript IE-9在使用输入类型文件时给出伪路径

Javascript IE-9在使用输入类型文件时给出伪路径,javascript,internet-explorer-9,Javascript,Internet Explorer 9,我无法阅读IE-9中的文件。我正在从url生成base64。在除IE-9之外的所有其他浏览器中,它都可以工作。有人能帮我吗? 我在IE-9中获得了c://fakepath/images.jpg if((navigator.userAgent.indexOf("MSIE") != -1 ) || !!document.documentMode == true )) //IF IE > 10 { tmppath = $("#hi").val(); cons

我无法阅读IE-9中的文件。我正在从url生成base64。在除IE-9之外的所有其他浏览器中,它都可以工作。有人能帮我吗? 我在IE-9中获得了c://fakepath/images.jpg

if((navigator.userAgent.indexOf("MSIE") != -1 ) ||  !!document.documentMode == true )) //IF IE > 10
      {
      tmppath = $("#hi").val();
      console.log("only in ie"+tmppath);
      }
else{
    var selectedFile = this.files[0];
tmppath = URL.createObjectURL(event.target.files[0]);
console.log("temp path other"+tmppath);
}

console.log("temp path"+tmppath);
<input name="hello1" type="file" id="hi" accept="image/*"/>
if((navigator.userAgent.indexOf(“MSIE”)!=-1)| |!!document.documentMode==true))//如果IE>10
{
tmppath=$(“#hi”).val();
控制台日志(“仅在ie中”+tmppath);
}
否则{
var selectedFile=this.files[0];
tmppath=URL.createObjectURL(event.target.files[0]);
console.log(“临时路径其他”+tmppath);
}
控制台日志(“临时路径”+tmppath);

您有针对IE9和更早版本的代码显式分支,并读取
输入的
值。
type=“file”
输入的
值总是有一个假路径(在所有浏览器上),因为不允许您知道文件的实际路径

另一个分支使用IE9不支持的
createObjectURL
。(IE9一点也不支持这一点。)

您必须提交一个包含文件输入的表单,并处理文件服务器端