Change utf-8 default charset response to get file names in other charsets

Hi,

i will use swfupload to upload some file names that contains accents and other spanish stuff. ...

When i upload a file with special characters, i think swfupload encode it to Utf8.

If I upload a file called áMàMéMèMíMìMóMòMúMù.doc
(its not commom, but its a example with all the accents)

echo $_FILES['filename']['name']

I get = ã¡mã mã©mã¨mã mã¬mã³mã²mãºmã¹

And then i can't put correctly the file name information to mysql.(which is in iso-8859-1)

I'm using iso-8859-1 encoding for entire web.
Php version: 4.5

How can i solve it? What i have to change in swfupload code to return the file name, at least with something similar like htmlentities(), or urlencode() ??

Thank you very mch.

Add this line before - not correct,see below

Add this line before retrieving file name:

Request.ContentEncoding=System.Text.Encoding.UTF8;

(Sorry for C# syntax only)

Where ?

Hi thank you for reply.

Is there any way to do the same on php?

gyphie's picture

Which version of SWFUpload?

Are you using the Flash 8 or Flash 9 version (I'm not asking which version of flash you have, but which swfupload SWF file you are using).

gyphie's picture

Unicode

My little bit of research reveals that PHP and character encoding is a sticky problem. This site was helpful.

SWFUpload for Flash Player 9 fully supports UTF-16 internally (according to the Docs). All data is either converted to encoded ascii or is sent as an octet-stream and doesn't undergo any encoding when POSTed to the server.

In my tests (Windows XP, FF and IE) I haven't had any problems with special characters.

Edit: I did some more testing and did have problems when actually trying to save the file to disk. Using the utf8_decode function as described below solved my problem too.

SWFupload file name iso-8859-1

It take me about 3 days to solve it. But as always happen, it finally works!

To help other people with same problem, I will explain my solution.

Very important: Read http://www.phpwact.org/php/i18n/charsets ( thankkks gyphie). That document has your medicine.

Add_file.php
is ISO-8859-1

upload.php
is utf-8

header('Content-Type: text/html; charset=UTF-8'); ( swfupload will send $_FILES['filedata']['name'] in UTF-8)

Becarefull with strtolower() and strtoupper(), because they are not ready to handle almost non english chars. ( read document above )

$temp = $_FILES['filedata']['name']; ( in UTF-8)
$file_name = utf8_decode($temp);

and then i can put the file name correctly on mysql.

SWFUPLOAD is great!

Thank you

I get the same error-resolved

http://dev.webking.cn/blog/Entry/Entry.aspx?Id=383

I'm using asp.net/C#.

-------------------------------------------------------------------
use utf-8 as all charset in web.config

I don't understand you

I don't understand your mean.

1)Where is your file "add_file.php"?

2)Add this to where?upload.php?

header('Content-Type: text/html; charset=UTF-8'); ( swfupload will send $_FILES['filedata']['name'] in UTF-8)

I have resolved this problem in very simple way:
Always use utf-8 as the charset(at least in scripts revolves swfupload-because I am working with asp.net,only config web.config),then add charset="gb2312"(for our Chinese language) in this line in default.aspx: