Upload class / filenames and "Umlaute" |
[eluser]LuckyFella73[/eluser]
Hi, I scripted a backend for a client who wants to manage his news by himself. There are some text fields and the possibility to upload pdf files. The problem is that I can't force the client to rename the pdf files before uploading and the filenames often contain german "umlaute" (ü,ö,ä or ß). The filename-entry in the DB is still correct when selecting a file with an "umlaut" but the filename of the uploaded file is kind of broken. Looks like a HTML page where you try to display "ä" and did not set the right encoding. I edited the upload class on line 938 like this: Code: # Anpassung wegen Umlaute: and it works so far but I wonder what would be smarter to do. Would you extend the upload class and just rewrite this function? Code: function _prep_filename($filename) Would be nice if the codeigniter upload class by default would be able to handle this kind of issues...
[eluser]steelaz[/eluser]
Unless there is a very good reason to use original file names, I always generate random file names when uploading: Code: $config['file_name'] = random_string('alnum', 16);
[eluser]LuckyFella73[/eluser]
Usually I do that in a simular way - most the times I set a "base-filename" and add a prefix related to the id of the DB entry or use timestamp. But in this case the client wants the pdf names to be like he uploaded them...
[eluser]steelaz[/eluser]
I haven't tried it myself yet, but there is new config file in CodeIgniter 2.0 for foreign characters - http://bitbucket.org/ellislab/codeignite..._chars.php and updated text helper with convert_accented_characters() function in it - http://bitbucket.org/ellislab/codeignite...php#cl-357
[eluser]LuckyFella73[/eluser]
Thank you for that links - I'll have a closer look at the scripts. Looks interesting - up to now I just don't get what the numbers in foreign_chars.php are standing for ..
[eluser]steelaz[/eluser]
Here's the reference to those numbers - http://www.utf8-chartable.de/unicode-utf...&htmlent=1
[eluser]simpleCoder[/eluser]
Hi Guys , I have still used $config['file_name'] = random_string('alnum', 16); but codeigniter does not rename the files i upload . I still see the raw file name . This is the code base i am using $config['upload_path'] = ASSET_PATH.'uploads'; $config['allowed_types'] = 'gif|jpg|png'; $config['max_size'] = '100'; $config['max_width'] = '1024'; $config['max_height'] = '768'; $config['remove_spaces'] = TRUE; $config['file_name'] = random_string('alnum', 16); $this->load->library('upload', $config); I have even tried the removing the config item $config['remove_spaces'] = TRUE; but still no luck in getting codeigniter to rename my upload files |
Welcome Guest, Not a member yet? Register Sign In |