This article mainly introduces the JS access, empty input type= "file" value (sample code) needs of friends can come to the reference, I hope to help you.
The Upload control (<input type= "file"/>) is used to browse and upload files on the client, and the path that the user chooses can be obtained by the Value property, but the Value property is read-only and cannot be assigned through JavaScript, which makes it impossible to pass through the value= "" Statement to empty it. It is easy to understand why only read, if you can assign values, then the user just open your Web page, you can upload the files on his computer. JS get <intput type=file/> Value code as follows: <html> <script language= ' javascript ' > function &n Bsp Show () { var p=document.getelementbyid ("File1"). Value document.getElementById ("s"). Innerhtml= "< Input id=pic type=image height=96 width=128/> "; document.getElementById ("pic"). Src=p; Alert (p); </script> <head> <title>MyHtml.html</title> </head> & lt;body> <input type= "file" Name= "File1" id= "File1" "Onpropertychange=" Show (); "/> <span the id=" s "></ span> </body> </html> Two ways to empty the value of the upload control (<input type= "file"/>) Method 1: Code As follows: <span id=span1> <input name=ab type=file> </span> <iNput name=button1 Type=button value= "by" Onclick=show () > <script LAN guage=javascript> function Show () { document.getElementById ("Span1"). Innerhtml= "< Input name=ab type=file> "; </script> Method 2: The code is as follows: function clearfileinput (file) {var form=document.createele ment (' form '); Document.body.appendChild (form); //Remember the location of the file in the old form Var pos=file.nextsibling; Form.appendchild (file); Form.reset (); Pos.parentNode.insertBefore (File,pos); Document.body.removeChild (form); }