——————————————————————
<script type= "Text/javascript" >
function Chkform () {
Get DOM
var mypic = document.forms[0].mypic;
for (var i = 0; i<mypic.files.length;i++) {
Remove one of the files
var file = Mypic.files[i];
var name = file.name;//file name, uppercase processing
Name = Name.substring (Name.lastindexof (".") +1). toUpperCase ();
Determine if the suffix of the file name meets the requirements
if (name!= "JPG" &&name!= "GIF" &&name!= ' PNG ' &&name!= ' BMP ') {
Alert ("Malformed");//prompt is incorrect
return false; Return an error directly and no longer submit the form
}
}
Submit Form
if (Mypic.files.length > 0)
Document.forms[0].submit ();
}
</script>
————————————————————————
<body style= "Text-align:center" >
<form action= "" method= "Post" enctype= "Multipart/form-data" name= "MyForm" onsubmit= "Chkform (); return false;" >
<label>
<input type= "File" Name= "Mypic" multiple/>
</label>
<label>
<input type= "Submit" name= "Submit" value= "Submission"/>
</label>
</form>
</body>
————————————————————————
File and print tips-limit file types for multiple file uploads