File upload encoding problems

Source: Internet
Author: User
For file Upload encoding problems, use Flash + PHP to batch upload files. PHP encountered the encoding problem when saving the file: PHPcode & lt ;? Phpheader (& quot; Content-Type: text/html; charset = utf-8 & quot;); file Upload encoding problems
Use Flash + PHP to batch upload files. PHP encountered encoding problems when saving files:
PHP code
  
  

The file name is very nonstandard, including Chinese, English, French, Russian ,...... Uncertain type. at this time, some files are saved, either garbled or truncated (all extensions are lost ). Iconv ('utf-8', 'gbk', $ _ POST ['FN ']). What is the problem here? What should I do?

------ Solution --------------------
Your current page uses UTF-8
Header ("Content-Type: text/html; charset = utf-8 ");


This should not be converted to gbk.
$ Uploadfile = $ uploaddir. iconv ('utf-8', 'gbk', $ _ POST ['FN ']);

Remove or
$ Uploadfile = $ uploaddir. iconv ('gbk', 'utf-8', $ _ POST ['FN ']);
Try
------ Solution --------------------
The GBK-encoded string does not contain the Russian characters. That is to say, it only applies to Chinese
We recommend that you use UTF-8 to save the file. the file name is garbled.
------ Solution --------------------
$ Uploadfile = $ uploaddir. base64_encode ($ _ POST ['FN ']).'. '. pathinfo ($ _ POST 'FN'], PATHINFO_EXTENSION );
------ Solution --------------------
What should you do if your data source is GBK.
Iconv uses // IGNORE to IGNORE special characters and convert them to UTF8 or rename them.
------ Solution --------------------
On your windows Server, can you enter Russian and Arabic to name a file?
The file name depends on the encoding of the customer's operating system. Generally, Chinese users use the Chinese version of windows. the default internal encoding of the system is GBK. how can GBK contain Russian and other languages. Or in other words you let the operating system code for the ISO-8859-1 user to download your Chinese name File, Chinese even if you convert to gbk is not the same as garbled. Simply name it randomly. Otherwise, there will be a good method. The User System code varies widely across the world, unless all of them use UTF-8 as the internal code, you don't have to bother using iconv.
You can see that I am using ubuntu now, and the system code is UTF-8. if you do not convert Chinese to Russian and French, if you do not convert GBK to a user like me, the code is garbled. Haha.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.