The file_exists function in PHP does not support Chinese name resolution,
In general, PHP often uses file_exists () to determine whether a file or folder exists, and returns true if it exists, otherwise false. However, this function does not return the correct value for the Chinese file name or the folder name if the Web page uses UTF8 encoding, and always returns false. After testing, the solution is obtained, and the reason for this is that PHP cannot be judged correctly due to different coding.
The following code is not able to return the correct value of the code, regardless of whether the file is returned in the not:
<?php; $file = "/attachment/21/0/Chinese. rar"; $newfile = DirName (__file__). $file; Echo file_exists ($newfile);? >
After testing, added a sentence to convert the UTF8 encoding into a GB2312 encoded statement, you can correctly judge:
<?php$file= "/attachment/21/0/Chinese. rar"; $newfile = DirName (__file__). $file; $file =iconv (' UTF-8 ', ' GB2312 ', $file); echo file_exists ($newfile);? >
http://www.bkjia.com/PHPjc/851352.html www.bkjia.com true http://www.bkjia.com/PHPjc/851352.html techarticle php file_exists function does not support the solution of Chinese name, in general, PHP often use file_exists () to determine whether a file or folder exists, if present, return true, otherwise ...