Note: As like windows .Net its not possible to show only specific file extensions,the only way is that we can validate it by manually as shown below.
function checkFileExtension(elem)
{
var filePath = elem.value;
if(filePath.indexOf('.') == -1)
return false;
var validExtensions = new Array();
var ext = filePath.substring(filePath.lastIndexOf('.') + 1).toLowerCase();
validExtensions[0] = 'pdf';
//validExtensions[1] = 'jpg';
//validExtensions[2] = 'txt';
for(var i = 0; i < validExtensions.length; i++)
{
if(ext == validExtensions[i])
{
return true;
}
}
alert('The file extension ' + ext.toUpperCase() + ' is not allowed,select PDF.');
return false;
}
--------------------------
FileUpload1.Attributes.Add("onchange", "return checkFileExtension(this);");
Tuesday, February 16, 2010
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment