Rank: Member
Groups: Member
Joined: 10/29/2006(UTC) Posts: 21
|
Quote:carinspector (12/19/2006)How do I remove the characters below from a filename......when a file with one of these characters is uploaded it locks the server down and I can't open, rename or delete the file....the only way to get the file off of the server is to delete the directory and re-create the directory again. ('!',"'",'\\','@','#','$','%','^','&','*','-','_',' ','|','}','{',']','[','/','?','`','~','+') I tried this in the upload.php script, but it didn't work. Code:// Replace invalid name syntax.
$replace = array('!',"'",'\\','@','#','$','%','^','&','*','-','_',' ','|','}','{',']','[','/','?','`','~','+');
foreach($replace as $value){
$imageName = str_replace("$value","",$imageName);
}
if($imageName=="") $imageName = "noname" . rand(1,1000);
Any help is greatly appreciated! It's probably easier to work from what you would accept, like numbers, letters, underscores and hyphens. In which case, something like the following should do it Code:$imageName = preg_replace("/[^A-Za-z0-9-_]/", "", $imageName);
Edited by user Tuesday, December 18, 2007 7:32:06 PM(UTC)
| Reason: Not specified
|