使用<input type = "file">
标签上传文件时,若两次上传的是同一个文件,查看浏览器网络面板发现没有出发网络请求。
【问题原因】
两次上传同一个文件时,<input type="file">
的value是一样的,所以不会触发onchange
事件。
【解决方案】
每次上传完成后,将所需信息保存,再将input的value值进行清空。
document.getElementById('the_inputfile').value = '';
或者重新赋值
var the_inputfile = document.getElementById('the_inputfile');
the_inputfile.outerHTML = the_inputfile.outerHTML;