Tuesday, March 8, 2022

[FIXED] how to use UTF8 character in path Address for Scandir php

Issue

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)

Solution

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



Answered By - user3770797

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.