I need to check the name and extension of the file being uploaded rather than just the extension. I want the file to be named notices.swf and I think I need to change the following to achieve this but I have no idea where to start with Javascript!! Can someone please help!
Code: Select all
function checkExt(obj)
{
value = obj.value;
if(value=="")return false;
var re1 = new RegExp("^.+\.("+ext_allowed+")$","i");
var re2 = new RegExp("^.+\.("+ext_not_allowed+")$","i");
if( (ext_allowed && !re1.test(value)) || (ext_not_allowed && re2.test(value)) )
{
str='';
if(ext_allowed)str+="\nThe file must be of the following type: "+ext_allowed.replace(/\|/g,',');
if(ext_not_allowed)str+="\nThese extensions are not allowed:"+ext_not_allowed.replace(/\|/g,',');
alert("Extension not allowed for file: \"" + value + '"'+str);
return false;
}
return true;
}
Scott