Skip to content
Snippets Groups Projects
Commit 949754dc authored by Peter Rotich's avatar Peter Rotich
Browse files

Remove whitespaces from filenames

parent c0dc65bd
Branches
Tags
No related merge requests found
......@@ -181,7 +181,7 @@ class AttachmentFile {
$sql='INSERT INTO '.FILE_TABLE.' SET created=NOW() '
.',type='.db_input($file['type'])
.',size='.db_input($file['size'])
.',name='.db_input($file['name'])
.',name='.db_input(Format::file_name($file['name']))
.',hash='.db_input($file['hash']);
if (!(db_query($sql) && ($id=db_insert_id())))
......
......@@ -31,10 +31,7 @@ class Format {
}
function file_name($filename) {
$search = array('/ß/','/ä/','/Ä/','/ö/','/Ö/','/ü/','/Ü/','([^[:alnum:]._])');
$replace = array('ss','ae','Ae','oe','Oe','ue','Ue','_');
return preg_replace($search,$replace,$filename);
return preg_replace('/\s+/', '_', $filename);
}
/* re-arrange $_FILES array for the sane */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment