Hi all,
I have an upload feature on my website that allows users to upload files to their blogs online.
In order to store the files on the server, I need to change some filenames (i.e: if they have symbols in them, etc.)...so I use the following code to strip the filename of characters:
$file_name = ereg_replace('[ ]+', '_', strtolower($file_name)); //replace spaces with underscores
$file_name = ereg_replace('[^a-zA-Z0-9 \. \_]', '', $file_name); //no characters allowed except periods and underscores
Now, I have a problem with this:
I uploaded file: 'hello_my_name's.doc' to test, and it came out like: 'hello_my_name\s.doc'. Shouldn't the second line strip the filename of apostrophes too? How can I fix this?
thanks.
-influx