当在PHP中将表单作为multipart / form-data发布时,UTF-8文本是乱码 [英] UTF-8 text is garbled when form is posted as multipart/form-data in PHP

查看:162
本文介绍了当在PHP中将表单作为multipart / form-data发布时,UTF-8文本是乱码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个PHP脚本来发布文章。它工作完全正常,直到我们添加文件上传支持。要启用文件上传,我们必须将标签的enctype更改为multipart / form-data。现在,每当我们尝试提交一个带有多字节字符的文章时,在通过$ _POST接收到它们后,它们会变为乱码。如果我们删除表单的enctype,那么它工作正常。

I have a PHP script to publish articles. It was working perfectly fine until we added the file uploading support. To enable uploading of files, we had to change enctype of tag to multipart/form-data. Now, whenever we try to submit an article with multibyte characters, they become garbled after you receive them via $_POST. If we remove the form's enctype, then it works fine.

我们已经在网上搜索了一个php中心解决方案,但没有运气。有一个标记的accept-charset属性,但它不工作在IE。有一个解决方案,JSP在当表单作为multipart / form-data发布时,UTF-8文本是乱码,但PHP没有解决方案。所以,请帮助!

We have searched for all over the web for a php centric solution but without luck. There is an accept-charset attribute of tag but it does not work in IE. There is a solution for JSP at UTF-8 text is garbled when form is posted as multipart/form-data but no solution for PHP. So, please help!

推荐答案

如果使用PHP 5.4.x,将mbstring.http_input从auto可能会解决您的问题。

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

这篇关于当在PHP中将表单作为multipart / form-data发布时,UTF-8文本是乱码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆