XUpload - Block certain characters in file naming.
Block certain characters in file naming.
Is there a way to program in the config file a way to alert a user if their file names contain any special chracters like @, #, %, etc. It would be nice to alert a user that they used a character not support in their file names. Like the way the script only allows certain extensions. Macintosh has a problem with certain chacters.
- PilgrimX182
- Posts: 2186
- Joined: Mar 22, 2006 1:39 pm
- PilgrimX182
- Posts: 2186
- Joined: Mar 22, 2006 1:39 pm
Ok then
In xupload.js update checkExt() function to this:
In this function we show error if filename contain '@','#','%'. You can add other 'bad' symbols to RegExp.
In xupload.js update checkExt() function to this:
Code: Select all
function checkExt(obj)
{
value = obj.value;
if(value=="")return true;
var re = new RegExp("^.+\.("+ext_allowed+")$","i");
if(!re.test(value))
{
alert("Extension not allowed for file: \"" + value + "\"\nOnly these extensions are allowed: "+ext_allowed.replace(/\|/g,',')+" \n\n");
return false;
}
var re = new RegExp("[\@\#\%]","i");
if(re.test(value))
{
alert("Selected filename contain bad characters!\n\n");
return false;
}
return true;
}