The File field in IE could not be emptied using jQuery to reset the File field

  • 2020-03-30 02:42:21
  • OfStack

Sometimes when doing the File upload will encounter a situation in which is the need to reset the entire form, but the problem is coming, ask other browsers do not have what problem, directly to reset the form or the trigger type for the reset button click event with respect to OK, but a strange flower, IE File of IE field cannot be empty, you may see is have no value, but you can print it out and see to know:
 
var fileVal = $('input[type="file"]').val(); 
alert(fileVal); 

Print out or the information of the file selected before the reset, how to do this, check a lot of information found in IE can use the following way to solve
 
$('input[type="file"]').attr('value',''); 
//or 
$('input[type="file"]').val(''); 

Of course, don't forget to reset the form.

Related articles: