// Place it between
<Script language = "JavaScript">
<! --
// Check the upload object checkfileupload (form name, file type, whether to upload, file size, minimum image width, minimum Image Height, maximum image width, and maximum image height, the name of the form storing the width and the name of the form storing the height)
Function checkfileupload (Form, extensions, requireupload, sizelimit, minwidth, minheight, maxwidth, maxheight, savewidth, saveheight ){
Document. mm_returnvalue = true;
If (extensions! = '') Var Re = new Regexp (" \. ("+ extensions. Replace (/,/GI," | ") +") $ "," I ");
For (VAR I = 0; I <form. elements. length; I ++ ){
Field = form. elements [I];
If (field. type. touppercase ()! = 'File') continue;
If (field. value = ''){
If (requireupload) {alert ('select the uploaded file! '); Document. mm_returnvalue = false; field. Focus (); break ;}
} Else {
If (extensions! = ''&&! Re. Test (field. Value )){
Alert ('the file does not match the upload type! \ N only supports the following types: '+ extensions + '. \ N select a new file to be uploaded according to regulations. ');
Document. mm_returnvalue = false; field. Focus (); break;
}
Document. pu_uploadform = form;
Re = new Regexp (". (GIF | JPG | PNG | BMP | JPEG) $", "I ");
If (Re. Test (field. Value) & (sizelimit! = ''| Minwidth! = ''| Minheight! = ''| Maxwidth! = ''| Maxheight! = ''| Savewidth! = ''| Saveheight! = '')){
SetTimeout ('If (document. mm_returnvalue) document. pu_uploadform.submit () ', 500 );
Checkimagedimensions (field. Value, sizelimit, minwidth, minheight, maxwidth, maxheight, savewidth, saveheight );
}}}
}
// -->
</SCRIPT>
// Place it in <body>
Onsubmit = "checkfileupload (this, 'gif, JPG, JPEG, PNG, BMP ', true ,'','','','','','', ''); Return document. mm_returnvalue"