10-01-2007, 03:05 PM
|
#3 (permalink)
|
|
Moderateur
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
|
Code:
// Returns true if the extension is invalid
function checkFileExtentions(form)
{
if (check_file_extentions == false)
{
return false;
}
// Regex of valid extensions
var re = /\.(jpg|jpeg|png|gif|bmp)$/i
// If we have a filename to check and it is invalid
if (form['filename'].value != '' && !form['filename'].value.match(re))
{
var name = form['filename'].value;
var ext = name.substr(name.lastIndexOf('.')+1).toLowerCase();
alert('Sorry, uploading a file with the extention "' + ext + '" is not allowed.');
return true;
}
return false;
}
|
|
|
|