RegisterRegister    SearchSearch   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

AJAX upload progress bar

File sharing script

File mirror script

Newsletter script
Block certain characters in file naming.

 
Post new topic   Reply to topic    SibSoft Ltd Forum Index -> XUpload
View previous topic :: View next topic  
Author Message
ap



Joined: 08 Jan 2007
Posts: 21

PostPosted: Jan 24, 2007 5:40 pm    Post subject: Block certain characters in file naming. Reply with quote

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.
Back to top
View user's profile Send private message
PilgrimX182



Joined: 22 Mar 2006
Posts: 2106
Location: UFO Lab

PostPosted: Jan 25, 2007 7:44 am    Post subject: Reply with quote

There's filaname_mask option in config in Pro version. But it don't show alert, just don't save file and set status=unallowed filename in POST request.
You can validate filename when selecting file with JS. Just add another regexp in checkExt function in xupload.js
Back to top
View user's profile Send private message Visit poster's website
ap



Joined: 08 Jan 2007
Posts: 21

PostPosted: Feb 02, 2007 5:26 pm    Post subject: Reply with quote

Not sure I followed you on this. What do I need to add, and where under the .js script and under the config script. Thanks
Back to top
View user's profile Send private message
PilgrimX182



Joined: 22 Mar 2006
Posts: 2106
Location: UFO Lab

PostPosted: Feb 05, 2007 7:02 am    Post subject: Reply with quote

Ok then Very Happy

In xupload.js update checkExt() function to this:

Code:

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;
}


In this function we show error if filename contain '@','#','%'. You can add other 'bad' symbols to RegExp.
Back to top
View user's profile Send private message Visit poster's website
ap



Joined: 08 Jan 2007
Posts: 21

PostPosted: Feb 09, 2007 7:41 pm    Post subject: Reply with quote

That seems to do the trick. Thanks
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    SibSoft Ltd Forum Index -> XUpload All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB © 2001, 2005 phpBB Group