Home > Backend Development > PHP Tutorial > PHP文件下传并解决中文文件名乱码有关问题

PHP文件下传并解决中文文件名乱码有关问题

WBOY
Release: 2016-06-13 10:54:56
Original
687 people have browsed it

PHP文件上传并解决中文文件名乱码问题

不说什么了,直接上代码,你们肯定能看懂

<?phpif (isset($_FILES['file'])){     $upload='upload/'.$_FILES['file']['name'];              if(is_uploaded_file($_FILES['file']['tmp_name'])){        //iconv函数解决上传文件中文名乱码的问题,但是不提倡文件名是中文的,特别是unix/linux环境下        if(!move_uploaded_file($_FILES['file']['tmp_name'],iconv('UTF-8','gb2312',$upload))){            echo 'failed';        }else{            echo 'success';        }    }    else{        echo 'failed';    }}?>
Copy after login
?

关于iconv函数的应用:string?iconv?( string?in_charset, string?out_charset, string?str?)

in_charset:传入的文件的格式

out_charset:输出的文件的格式

str:文件路径

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