UTF-8 in database: special characters not working

139 views
Skip to first unread message

Konfusion

unread,
Aug 25, 2014, 10:56:14 AM8/25/14
to jquery-f...@googlegroups.com

Hi,

writing special characters into the database fails. I use the script exactly as described at https://github.com/blueimp/jQuery-File-Upload/wiki/PHP-MySQL-database-integration. The file names in files/ directory are correct. Upload/Download works as expected.

However, the db entries in "name", "title" and "description" have e.g. ü instead of ü etc...

Since this issue comes up with the unmodified script – I just downloaded the zip and extended with db-integration – I'm wondering if I am the only one having problems writing special characters into the database? Is that a known issue – and ... can it be solved?

The table is created with charset utf8. I'm testing this script both stand-alone and integrated in the final project. The fault must be happening BEFORE the database. I can manipulate the entries e.g. by that:

---------------------------------------------------------
index.php ORIGINAL
uploading file "Mühle.jpg"

protected function handle_file_upload($uploaded_file, $name, $size, $type, $error,
            $index = null, $content_range = null) {
        $file = parent::handle_file_upload(
            $uploaded_file, $name, $size, $type, $error, $index, $content_range
        );
        if ...

The saved file is still named Mühle.jpg
The db entry for "name" is 
Mühle.jpg
---------------------------------------------------------

index.php manipulated 1
uploading file "Mühle.jpg"

protected function handle_file_upload($uploaded_file, $name, $size, $type, $error,
            $index = null, $content_range = null) {
        $file = parent::handle_file_upload(
            $uploaded_file, utf8_encode($name), $size, $type, $error, $index, $content_range
        );
        if ...

The saved file is named Mühle.jpg
The db entry for "name" is Mühle.jpg
---------------------------------------------------------

index.php manipulated 2
uploading file "Mühle.jpg"

protected function handle_file_upload($uploaded_file, $name, $size, $type, $error,
            $index = null, $content_range = null) {
        $file = parent::handle_file_upload(
            $uploaded_file, utf8_decode($name), $size, $type, $error, $index, $content_range
        );
        if ...

An error occurs: Error SyntaxError: Unexpected end of input
Nevertheless it's possible to download the file after reload.

The saved file is named M%FChle.jpg
The db entry for "name" is Mühle.jpg

---------------------------------------------------------

Is there someone feeling comfortable with stuff like that? Is it only me having that problem?

Thanks, great script though

cuiq...@gmail.com

unread,
Aug 15, 2018, 7:11:09 PM8/15/18
to jQuery-File-Upload
  protected function get_upload_path($file_name = null, $version = null) {
     $file_name = utf8_decode($file_name) ? utf8_decode($file_name) : '';
...

That solved the problem for me.
Reply all
Reply to author
Forward
0 new messages