<input type=‘file’> for IE gives full path, need file name only

前端 未结 7 1150
眼角桃花
眼角桃花 2020-11-29 04:20

When perform uploading from IE browser, that my backend(org.apache.commons.fileupload) gets full file path.

For other non-IE browsers it gets filename and it\'s OK b

7条回答
  •  被撕碎了的回忆
    2020-11-29 05:04

    There is actually a pretty easy workaround if you are uploading with FormData via Xhr. The FormData.append api allows for you to pass in the filename as the 3rd argument.

    const formData = new FormData();
    //explicitly setting the file name works in IE 11
    formData.append('file', file, file.name);

提交回复
热议问题