Jump to content

Characters to keep out of text files


railgun

Recommended Posts

You can generally have any file name in the db, just make sure to mysql_real_escape_data for them. If you want them to be SEO friendly then you tend to want to replace anything but alphanumeric and _ -s. If you do not care about that you should not have a problem. Just make sure when the file is uploaded to rename it to a hash of the name so it does not create invalid files (such as uploading a file with certain charaters can make that file undeleteable).

 

Moving to the regex forum so someone can provide a regex solution to replace all non alphanumeric if you so desire that.

Adding onto the SEO suggestion the above posted suggested, the regex i would use for a nice SEO friendly name will be

 


'#^[A-Z0-9._-]#si'
[/cODE]

 

Basically that allows any alphanumeric character, an underscore, a dash or a period.

 

You might want to add or remove constraints as you wish. Windows doesn't allow slashes, arrows, colon, asterick, question mark bar or quotation marks in file names so you might want to prevent files to be named this incase a user downloads the file and gets an error on his/her windows pc.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.