The JS code is as follows:
function CheckFile(obj) { var array = new Array('gif', 'jpeg', 'png', 'jpg'); //The file type that can be uploaded if ( == '') { alert("Let's choose the picture you want to upload!"); return false; } else { var fileContentType = (/^(.*)(\.)(.{1,8})$/)[3]; //This file type regular is very useful :) var isExists = false; for (var i in array) { if (() == array[i].toLowerCase()) { isExists = true; return true; } } if (isExists == false) { = null; alert("The uploaded image type is incorrect!"); return false; } return false; } }
The foreground code is as follows:
<asp:FileUpload ID="FileUpload1" runat="server" onchange="CheckFile(this);"/>
The above is the entire content of the upload file type instance code of JS control FileUpload brought to you. I hope everyone supports me~