File Upload Library and special characters - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=11) +--- Thread: File Upload Library and special characters (/showthread.php?tid=72094) Pages:
1
2
|
RE: File Upload Library and special characters - jreklund - 11-24-2018 No, I wanted you to delete that part. And make a test upload, too see if that function where the problem. But in your last post you said that it looked good in HTML, so it must be your PHP code that's the problem. RE: File Upload Library and special characters - marwin - 11-24-2018 OK so i did a quick extension to change the name - that works: return filename.replace('(', '_').replace(']', '_').replace('ä', 'ae').replace('ü', 'ue').replace('ö', 'oe').toLowerCase(); -> filename special characters are replaced and file is stored with the correct name. Before I extend this to cover the remaining characters, I ran in the next problem: now the file remains in the tmp-upload and is no longer moved to the proper folder. not even the ones that were moved before. That part I dont understand. EDIT I think I tempered at the wrong location. The problem seems to actually be with the \system\libraries\upload.php where the filename should be sanitised further. Is there a config setting to limit the permissable characters? RE: File Upload Library and special characters - marwin - 11-24-2018 OK i solved it in a different way. since I actually want to move the files from temp to a different folder I added this to the file moving: // Move files foreach ($this->data['data']['form_data']['userfile'] as $key => $value) { $new_value = preg_replace("/[^a-zA-Z0-9.]/", "_", $value); rename('./uploads_tmp/' . $session_id . '/' . $value, './uploads/' . $new_value); } // Remove temp folder rmdir('./uploads_tmp/' . $session_id . '/'); This works. |