The solution to the problem that file_exists does not support Chinese file names

WBOY
Release: 2016-07-25 08:56:54
Original
1561 people have browsed it
This article introduces how to solve the problem that the file_exists() function does not support Chinese file names. Here is a method for your reference.

When using file_exists() to determine whether a file or folder exists, it returns true if the file or folder exists, otherwise it returns false.

However, this function cannot return the correct value for Chinese file names or folder names, and always returns false. I thought of a solution and would like to share it.

Code:

<?php
//解决file_exists不支持中文文件名的问题
$filename = iconv("UTF-8","GB2312",$filename);  
if (!file_exists($filename)) {  
     return false;  
}  
//经过如上的转换,则对中英文就都可以支持了
?>
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