How to get the filename from the Javascript FileReader?

前端 未结 3 1605
一整个雨季
一整个雨季 2020-12-10 10:26

I\'m using the Javascript FileReader to load an image in the browser:

e = e.originalEvent;
e.dataTransfer.dropEffect = \'copy\';
this.documentFile = e.dataTr         


        
3条回答
  •  时光取名叫无心
    2020-12-10 11:07

    This is prob not the best solution, BUT it worked for me.

    var reader = new FileReader();
    reader.fileName = file.name // file came from a input file element. file = el.files[0];
    reader.onload = function(readerEvt) {
        console.log(readerEvt.target.fileName);
    };
    

    Not the best answer, but a working one.

提交回复
热议问题