0

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)
user3770797
  • 374
  • 5
  • 24
  • سلام. این دوتا لینک رو یه نگاهی بنداز: https://stackoverflow.com/questions/22990072/scandir-in-php-with-special-hungarian-characters https://stackoverflow.com/questions/3544772/readdir-and-scandir بعدش گوگل رو هم بگرد، حتما کسی بوده با این مشکل برخورده باشه: https://www.google.com/search?sclient=psy-ab&q=utf8+Scandir+php&oq=utf8+Scandir+php&gs_l=serp.3...90157.97443.0.100148.7.7.0.0.0.0.0.0..0.0....0...1.1.64.psy-ab..7.0.0.uRgxw9rYKHs&pbx=1&bav=on.2,or.&biw=1024&bih=662&ech=1&psi=5YlqWfWOJ8PVwQLFzZnIDw.1500154339585.3&ei=5YlqWfWOJ8PVwQLFzZnIDw&emsg=NCSR&noj=1 موفق باشی – msoa Jul 15 '17 at 21:46

1 Answers1

2

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

user3770797
  • 374
  • 5
  • 24