UTF-8 text gets distorted when form is submitted as multipart / form-data in PHP

I have a PHP script to publish articles. It worked fine until we added support for downloading files. To enable file upload, we had to change the enctype of the tag to multipart / form-data. Now, when we try to send an article with multibyte characters, they become garbled after you receive them through $ _POST. If we remove the enctype form, then it works great.

We searched the Internet for a solution for the php center, but with no luck. There is an accept-charset tag attribute, but it does not work in IE. There is a solution for JSP in the UTF-8 text is distorted when the form is submitted as multipart / form-data , but there is no solution for PHP. So please help!

+1
source share
2 answers

if you are using PHP 5.4.x, setting mbstring.http_input from "auto" to "pass" may solve your problem.

+2
source

Reinstalling apache and recompiling php fixed it for some ppl on linux.

I had the same thing on my local host, but this did not happen on the production server. My local WAMP, LAMP products, all have the same version.

So for me, this works with them: CentOs 6.3, php 5.4, Apache 2.2.15

Btw, in my local, mb_detect_encoding () shows 'UTF-8', but the string is mess anyway.

0
source

Source: https://habr.com/ru/post/947003/


All Articles