|
Posted by Good Man on 05/14/07 18:09
"Beauregard T. Shagnasty" <a.nony.mous@example.invalid> wrote in
news:0KM1i.15246$yM2.5488@bgtnsc04-news.ops.worldnet.att.net:
> Though it would likely be much easier if you were to strip out all
> characters except alpha, numeric, and the underscore prior to storage
> (file and database entry). Perhaps replace spaces with underscores.
I agree. Here's what I use to "clean" the filenames of all uploaded
files:
function cleanFile ($filename) { //clean up the file name
$filename = str_replace(" ","_",$filename);
$filename = str_replace("\\","",$filename);
$filename = str_replace("/","",$filename);
$filename = str_replace("|","_",$filename);
$filename = str_replace("'","",$filename);
$filename = str_replace("\"","",$filename);
$filename = str_replace("","",$filename);
$filename = str_replace("`","",$filename);
$filename = str_replace("*","",$filename);
$filename = str_replace("$","",$filename);
$filename = str_replace("%","percent",$filename);
$filename = str_replace("^","",$filename);
$filename = str_replace("!","",$filename);
$filename = str_replace("@","",$filename);
$filename = str_replace("?","",$filename);
$filename = str_replace(":","",$filename);
$filename = str_replace(";","",$filename);
$filename = str_replace(",","",$filename);
$filename = str_replace("<","",$filename);
$filename = str_replace(">","",$filename);
$filename = strtolower($filename);
return $filename;
}
Navigation:
[Reply to this message]
|