function LastName () {
Get the file path you want to upload
var filepath = document.getElementById ("File1"). Value;
To avoid the problem of escaping the backslash, it will be converted
var re =/(\\+)/g;
var filename=filepath.replace (Re, "#");
Clipping a path string
var one=filename.split ("#");
Gets the last, or file name, of the array
var two=one[one.length-1];
Then intercept the file name to get the suffix name
var three=two.split (".");
Gets the last string intercepted, which is the suffix name
var last=three[three.length-1];
Add the type of suffix you want to determine
var tp = "Jpg,gif,bmp,jpg,gif,bmp";
Returns the position of a qualified suffix name in a string
var rs=tp.indexof (last);
If the returned result is greater than or equal to 0, the description contains the file types that are allowed to upload
if (rs>=0) {
return true;
}else{
Alert ("The upload file you selected is not a valid picture file! ");
return false;
}
}
--From the network
Intercepting the uploaded file path