how to use UTF8 character in path Address for Scan

2019-08-26 07:30发布

问题:

how to use UTF8 character in path Address for Scandir php

my folder name is: 61-تست تست

i have error in scandir and DirectoryIterator.

after change folder name to 61 fix my problem but in need full name.

$folder = '61-تست تست';
        $path    = 'files/'.$folder;

print_r(scandir($path));

        foreach (new \DirectoryIterator($path) as $file) {
            if(!$file->isDir())
            {
                echo $file->getFilename() . "<br>";
            }
        }

error:

    UnexpectedValueException

The system cannot find the file specified. (code: 2)

DirectoryIterator::__construct(D:/wamp64/www/project/web/files/61-تست تست,D:/wamp64/www/project/web/files/61-تست تست): The system cannot find the file specified. (code: 2)

回答1:

ScanDir good work in PHP 5.6 LINUX but upload files only with FTP and dont work in PHP 5.6 windows for fix this in windows you are use WFIO ext or Upgrade to PHP 7.1



标签: php utf-8 yii yii2