The JS code is as follows:
function Checkfile (obj) {
var array = new Array (' GIF ', ' jpeg ', ' png ', ' jpg ');//Can be uploaded file type
if (Obj.value = = ") {
alert ("Let's choose the picture to upload!");
return false;
}
else {
var filecontenttype = Obj.value.match (/^ (. *) (\.) (. {1,8}) $/) [3]; This file type is useful:
var isexists = false;
for (var i in array) {
if (filecontenttype.tolowercase () = = Array[i].tolowercase ()) {
isexists = true;
return true;
}
if (isexists = = False) {
obj.value = null;
Alert ("Incorrect upload image type!");
return false;
}
return false;
}
asp.net foreground code is as follows:
<asp:fileupload id= "FileUpload1" runat= "Server" onchange= "Checkfile" (this); " />
The above is small series for everyone to bring the JS control fileupload upload File type instance code all content, I hope we support cloud Habitat Community ~