Yii upload file move_uploaded_file and rename function reports error

WBOY
Release: 2016-07-29 09:12:52
Original
1336 people have browsed it

This is because the character encoding of PHP is different from that of Windows. The Simplified Chinese version of Windows generally uses gbk or gb2312 encoding for naming file names. Most of the values ​​of non-ASCII string variables in PHP use utf8 encoding (of course, this default value can be modified...). The $name variable needs to be converted to gbk encoding before it can be named and stored in the Windows file system. You can use the mb_convert_encoding function to convert the encoding of a string.

Assume that php is utf8 encoding, then change move_uploaded_file($tmp_name,'upload/' .$name); in the code to move_uploaded_file($tmp_name,'upload/'.mb_convert_encoding($name));

The above introduces the error reported by move_uploaded_file and rename functions of yii uploaded files, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!