filesize stat failed

12,904

I've encountered this before; file system encoding is difficult and hard to predict, but this usually works for me:

stat(iconv('UTF-8', 'ISO-8859-1', $filename));

It just converts the filename from utf8 to iso8859-1 and tries.

This is tricky though, just look at this page for a juicy dialog in the post comments: http://www.rooftopsolutions.nl/blog/filesystem-encoding-and-php

Share:
12,904
Daan
Author by

Daan

I'm a developer.

Updated on June 04, 2022

Comments

  • Daan
    Daan about 2 years

    I have a php script running, which loops through all files in a specified directory. It returns name, filesize, modified_date etc. for each file it finds. The script returns the info for most of the files correctly, except for the ones that have Chinese or other symbols in it. Then I get the famous filesize stat failed error (warning). How would I solve this, without changing the filenames?

    I will provide code if needed.