Pure PHP Upload 2 Support Product Page
Under consideration
remove special char
Shared 30 May 2011 13:33:02
1
likes this idea
30 May 2011 13:33:02 Ubaldo Uby posted:
now is$fileName = preg_replace("/\s+|;|\+|=|\[|\]|'|,|\\|\"|\*|<|>|\/|\?|\:|\\$|&|\|/i", "_", $fileName);
what do you think for the italian people?? []
$a = array('/(à|á|â|ã|ä|å|æ)/','/(è|é|ê|ë)/','/(ì|í|î|ï)/','/(ð|ò|ó|ô|õ|ö|ø)/','/(ù|ú|û|ü)/','/ç/','/þ/','/ñ/','/ß/','/(ý|ÿ)/','/(=|\+|\/|\\\|\.|\'|\_|\\n| |\(|\))/','/[^a-z0-9_ -]/s','/-{2,}/s'); $b = array('a','e','i','o','u','c','d','n','s','y','-','','-'); $fileName = trim(preg_replace($a, $b, strtolower($str)),'-');
Edited by - Ubaldo Uby on 30 May 2011 13:33:17
Replies
Replied 30 May 2011 19:24:48
30 May 2011 19:24:48 Ubaldo Uby replied:
a little better
// Cleanup illegal characters function cleanUpFileName(&$file) { $this->debug("[b]CleanUp FileName[/b]<br/>"); $fileName = $file->getFileName(); $desinenza = substr($fileName,strrpos($fileName,"."),strlen($fileName)-strrpos($fileName,".")); $nome_file_da_pulire = substr($fileName,0,strlen($fileName)-(strlen($fileName)-strrpos($fileName,"."))); $a = array('/(à|á|â|ã|ä|å|æ)/','/(è|é|ê|ë)/','/(ì|í|î|ï)/','/(ð|ò|ó|ô|õ|ö|ø)/','/(ù|ú|û|ü)/','/ç/','/þ/','/ñ/','/ß/','/(ý|ÿ)/','/(=|\+|\/|\\\|\.|\'|\_|\\n| |\(|\))/','/[^a-z0-9_ -]/s','/-{2,}/s'); $b = array('a','e','i','o','u','c','d','n','s','y','-','','-'); $fileName = preg_replace($a, $b, strtolower($nome_file_da_pulire)).$desinenza; $fileName = substr($fileName, strrpos($fileName, ':')); $fileName = preg_replace("/\s+|;|\+|=|\[|\]|'|,|\\|\"|\*|<|>|\/|\?|\:|\\$|&|\||#/i", "_", $fileName); if ($this->nameToLower) { $fileName = strtolower($fileName); } $this->debug("new filename = <font color=\"#000099\">[b]".$fileName."[/b]</font><br/>"); $file->setFileName($fileName); }
Edited by - Ubaldo Uby on 30 May 2011 19:25:25
Replied 31 May 2011 08:52:00
31 May 2011 08:52:00 Miroslav Zografski replied:
Hello Ubaldo,
Nice work you did. Will pass this to developers to consider including in next update.
Thanks.
Regards,
Nice work you did. Will pass this to developers to consider including in next update.
Thanks.
Regards,