|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-10-30 18:25 UTC] banu_daniel1 at yahoo dot com
Description:
------------
it seems that this bug was reported and it says there "Marking as closed... also please try a newer version. " but the problem is still there even on windows xp so this is the problem
filesize function dose not work with filenames with unicode characters.
on linux version i don't have this problem.
Reproduce code:
---------------
$size=sprintf("%u", filesize($eps["FNAME"][$f])
Actual result:
--------------
Warning: filesize() [function.filesize]: stat failed for E:\Emilya・Chad.mpg in C:\WWW\files.php on line 45
Just an example.
Patchessa (last revision 2023-01-09 12:42 UTC by hayatsizyazilim at gmail dot com)Pull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 22:00:01 2025 UTC |
The filesystem functions have no problem with unicode (utf-8). But you must use a unicode char, and not a HTML entity which are represent a unicode char. | $size= sprintf("%u", | filesize(html_entity_decode($eps["FNAME"][$f], | ENT_COMPAT, 'UTF-8') | ) | ); Regards, Carstenwell, i copy/paste the name of the file and did this echo filesize("E:\Emilya?Chad.mpg"); and i have the same result and also this if (file_exists("E:\Emilya?Chad.mpg")) echo "ok" and is not working. this is the hex value 453A456D696C7961FA436861642E6D7067> this is the hex value 453A456D696C7961FA436861642E6D7067 Well, this HEX looks like ISO-8859-1 and not UTF-8: 453A456D696C7961FA436861642E6D7067 E : E m i l y a ? C h a d . m p g (The char between Emilya and Chad is a latin small letter u with acute) > if (file_exists("E:\Emilya?Chad.mpg")) echo "ok" and is not working. In this string we have (in UTF-8): 453A5C456D696C7961C2B7436861642E6D7067 E : \ E m i l y a ? C h a d . m p g (or in ISO-8859-1): 453A5C456D696C7961B7436861642E6D7067 E : \ E m i l y a ? C h a d . m p g (The char between Emilya and Chad is a middle dot) This works here: <?php $name = 'Emilya?Chad.mpg'; touch($name); echo filesize($name); ?> What's the codepage/language of your system? What's the result (filename) if you use glob() or the directory class dir()? Regards, Carsteni've don this <? if (file_exists("D:\Downloads\動之家發佈\ハヤテのごとく01\DVD_VIDEO.MDS")) echo "ok"; else echo "files dose not exist<br>\n"; print_r(glob("D:\Downloads\動之家發佈\ハヤテのごとく01\DVD_VIDEO.MDS")); //exemple from help $d = dir("D:\Downloads\動之家發佈"); echo "Handle: " . $d->handle . "\n"; echo "Path: " . $d->path . "\n"; while (false !== ($entry = $d->read())) { echo $entry."<br>\n"; } $d->close(); ?>> print_r(glob("D:\Downloads\動之家發佈\ > ハヤテのごとく01\ > DVD_VIDEO.MDS")); Sorry, I was not clear enought... Don't provide a parameter to glob(). Just look what glob() returns: | $dirs = glob('"D:/Downloads/*', GLOB_ONLYDIR); And now analyse the array $dirs. The value of one of the keys must be the directory "D:/Downloads/動之家發佈", and look how this directory is stored in the array. Regards, Carsten$dirs = glob('"D:/Downloads/*', GLOB_ONLYDIR); print_r($dirs); result is Array ( )> dirs = glob('"D:/Downloads/*', GLOB_ONLYDIR); --^ Please remove my typo... (you have not seen that?): | dirs = glob('D:/Downloads/*', GLOB_ONLYDIR); Regards, Carsten