File Upload with Special Chars

QuestionsFile Upload with Special Chars
Martin Schlosser asked 5 years ago

When Uploading files with German Special-Chars like ö,ü,ä the file is saved on the Server like this:

Filename: Süd.pdf will be saved as Süd.pdf.

In Database the Name is corretly saved as Süd.pdf

How can i saved the file with the correct Name “Süd.pdf”?

6 Answers
Abu Ghufran Staff answered 5 years ago

I am unable to generate this issue. When uploading file on linux server, it is displayed as Süd.pdf but downloaded correctly as Süd.pdf. Looks like its just a display issue. You can set display encoding to UTF8 and it should work as expected like shown correctly in grid.

https://live.staticflickr.com/65535/49577936181_4965dec16b_b.jpg

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Martin Schlosser answered 5 years ago

The Problem is, that the generated Link from Database goes to Süd.pdf

When clicking the Link the file is not found on the Server because the file is saved as Süd.pdf.

Why is the file renamed on Upload/saving on the Server.

Abu Ghufran Staff answered 5 years ago

I’m unable to generate this issue.

Can you test using FTP client if file name is actually renamed OR it’s just because of browser display encoding?

Screenshot would help.

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Martin Schlosser answered 5 years ago

The file IS renamed and saved with as Süd.pdf.

https://imgur.com/54sth0c

Abu Ghufran Staff answered 5 years ago

Please have a remote session. I’m unable to get the issue cause it’s not being generated here in Windows/Linux servers. My hangouts id is [email protected]

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Abu Ghufran Staff answered 3 years ago

This was php bug and issue is fixed in php 7.1: https://bugs.php.net/bug.php?id=47096

Alternate approach for older php versions was to modify the code in jqgrid_dist.php and search replace code of move_uploaded_file with following:

$destname = iconv('UTF-8', 'CP1252', $name);
if ( @move_uploaded_file($tmp_name, "$uploads_dir/$destname") )
{
$msg = "$uploads_dir/$name";
}

Recheck variable names as it may differ w.r.t. your library version.

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Your Answer

11 + 15 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?