Type The Below Query In ASPX page....
function checkFileExtension(elem) {
var
filePath = elem.value;
var
ext = filePath.substring(filePath.lastIndexOf('.')
+ 1).toLowerCase();
var
validExtensions;
validExtensions = new Array();
validExtensions[0] = 'jpg';
validExtensions[1] = 'jpeg';
validExtensions[2] = 'bmp';
validExtensions[3] = 'png';
validExtensions[4] = 'gif';
for
(var i = 0; i < validExtensions.length; i++)
{
if
(ext == validExtensions[i])
return
true;
}
alert('The
file extension ' + ext.toUpperCase() + ' is
not allowed!');
elem.value = "";
return
false;
}
Type The Below Query In ASPX.CS page Load....
protected void
Page_Load(object sender, EventArgs e)
{
ImageUpload.Attributes.Add("onchange", "return
checkFileExtension(this);");
}
No comments:
Post a Comment