-2

I wasn't able to read the file in IE-9. I am generating base64 from the url. In all the other browsers it works, except for IE-9. Can anyone please help me with this? I am getting c://fakepath/images.jpg in IE-9

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/*"/>
Deve1
  • 63
  • 1
  • 6

1 Answers1

0

You have code explicitly branching for IE9 and earlier and reading the value of the input. The value of a type="file" input always has a fake path (on all browsers), because you are not allowed to know the actual path of the file.

The other branch makes use of createObjectURL, which isn't supported by IE9. (IE9 doesn't suport the File API at all.)

You'll have to submit a form containing the file input, and deal with the file server-side.

T.J. Crowder
  • 1,031,962
  • 187
  • 1,923
  • 1,875