The following code implements the control form submission
Copy codeThe Code is as follows:
Function shangchuan (){
Var filepath = document. getElementById ("file"). value;
Alert (filepath );
If (filepath = ""){
Alert ("select the uploaded file! ");
Document. getElementById ("file"). disabled = true;
}
Var extname = filepath. substr (filepath. length-3, filepath. length );
Alert ("extname:" + extname );
// Var extname = filepath. substring (filepath. lastIndexOf (".") + 1, filepath. length );
// Extname = extname. toLowerCase (); // case sensitive
If (extname! = "Bmp" & extname! = "Jpg" & extname! = "Gif "){
Alert ("only bmp, jpg, and gif images can be uploaded! ");
Document. getElementById ("file"). disabled = true;
}
Else {
Document. getElementById ("file"). disabled = false;
}
}
Copy codeThe Code is as follows:
<Tr>
<Td> <input name = "file12" style = "width: 200px; height: 100px;" type = "file" id = "file"> </td>
</Tr>
<Tr>
<Td align = "center"> <button onclick = "shangchuan ()"> Click Upload </button> </td>
</Tr>