Home > Backend Development > PHP Tutorial > php上传文件名中包含中文字符的附件

php上传文件名中包含中文字符的附件

WBOY
Release: 2016-06-23 13:33:49
Original
955 people have browsed it

我们在上传附件的时候,常会要上传一些附件名称包含中文字符的附件,上传成功之后,会发现上传的附件其实是一个空文件。我就遇到过这类问题。

下面我们来解决这类问题

解决这类问题其实很简单

例如我们的php编码是utf-8,我们只要在move_uploaded_file()的时候,将保存附件的路径编码换成和php编码一致就可以解决

如下代码就能解决

move_uploaded_file($file["tmp_name"], iconv("utf-8","utf-8",$filename));
Copy after login

如下代码就可能出现附件为空的情况

move_uploaded_file($file["tmp_name"], $filename);
Copy after login

再次记录一下,以便后面不会再为这问题而纠结


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template