0

I have to upload in IE8 in enterprise mode.

In IE9 or higher I can do like

<input type="file" accept="jpg" id="inputer" onchange="uploadImage(event)">

function uploadImage (event){
var fileList = event.target.files;
    console.log(fileList);
}

but how do that in IE8, because in IE8 event.target == undefined?

It was researched here

I have to upload that files into server

Dred
  • 1,076
  • 8
  • 24
  • Have you even researched this? Beyond SO – GetSet Sep 16 '20 at 04:15
  • this... what? ) – Dred Sep 16 '20 at 04:15
  • Ok, why do you need IE8 support? – GetSet Sep 16 '20 at 04:16
  • because it is legacy and enterprise solution.... – Dred Sep 16 '20 at 04:16
  • So have you researched keywords "supporting IE8 in modern times"? Maybe a library exists. Just saying, you do have access to internet search engines presumably – GetSet Sep 16 '20 at 04:17
  • If you mean We have to stop support IE8, so it is not solution for current situation. We are going to change our browser since 8 till 11, but not now – Dred Sep 16 '20 at 04:20
  • No am saying likely if any research was done, you wouldnt be here asking this question – GetSet Sep 16 '20 at 04:21
  • IE8 is dead. So best bet is do outside research – GetSet Sep 16 '20 at 04:22
  • Looks like the code you are using is not supported in the IE 8 version. As a workaround for this issue, I suggest you refer to the [answer](https://stackoverflow.com/a/15665917/10309381) in the link. It may help you to solve your issue. Other than that it is recommended to use the latest Microsoft browsers or at least move to the IE 11 version. IE 8 is out of the support scope of Microsoft. Thanks for your understanding. – Deepak-MSFT Sep 17 '20 at 06:32
  • Unfortunatelly it is too late, but I think it is not bad answer. Thank you for your comment. We found workaround with ActiveXObject(FileSystem.Scripting) – Dred Sep 18 '20 at 07:48
  • Thanks for sharing the solution to the issue. I suggest you post your solution as an answer for this thread and try to mark your own answer as an answer to this question after 48 hrs when it is available to mark. It can help other community members in the future in similar kinds of issues. Thanks for your understanding – Deepak-MSFT Sep 21 '20 at 09:44
  • Ok, I'll do that in close future :) – Dred Sep 23 '20 at 09:29
  • I did my answer, How does it look? – Dred Sep 30 '20 at 08:09

1 Answers1

0

We did some function like

var FileReader = (function () { 

   function YourOwnEncoderStringTOArray(str){//your code}
   
   function FileReader(){

        var reader = new ActiveXObject("Scripting.FileSystemObject");

        this.getFileSize = function(filename){
        var file = reader.getFile(filename);
        return file && file.size;
    };

    this.getBytes = function (filename){
        var file = reader.getFile(filename);
        var size = file.size;
        var stream = file.OpernAsTextStream(1,0);
        var str = stream.Read(size);
        stream.Close();
        return YourOwnEncoderStringTOArray(str);
    };

}
return FileReader;
})();

And you can call it from your js like

window.YourFunc = function(event){


 var filename = $('myElementId').val();
    var fileReader = new FileReader();
    var fileSize;
    try{
      fileSize = fileReader.getFileSize(filename);
    }catch(e){
    // your code to explain why fileReader do not answer
    }
}
Dred
  • 1,076
  • 8
  • 24