Welcome Guest, Not a member yet? Register   Sign In
File Upload Library and special characters

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.

(This post was last modified: 11-24-2018, 03:42 AM by marwin.)

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.


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?

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.

Theme © iAndrew 2016 - Forum software by © MyBB