Sometimes, when uploading files, you may encounter a situation where you need to reset the entire form, but the problem is that other browsers do not have any problems, it is okay to directly reset form or trigger the click Event of the button whose type is reset, but IE is amazing, and the File field in IE cannot be cleared. What you may see is that there is no value, but you can print it out and see it:
Copy codeThe Code is as follows:
Var fileVal = $ ('input [type = "file"] '). val ();
Alert (fileVal );
The printed file is the information of the file selected before reset. Should this be done? I checked a lot of information and found that the following methods can be used in IE to solve the problem:
Copy codeThe Code is as follows:
$ ('Input [type = "file"] '). attr ('value ','');
// Or
$ ('Input [type = "file"] '). val ('');
Of course, don't forget to reset the form.