php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #50197 long filenames
Submitted: 2009-11-16 22:40 UTC Modified: 2013-10-15 12:13 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: jandidrik dot fagerlid at hotmail dot com Assigned: pajoye (profile)
Status: Not a bug Package: Filesystem function related
PHP Version: 5.3.0 OS: winxp 32bit
Private report: No CVE-ID: None
 [2009-11-16 22:40 UTC] jandidrik dot fagerlid at hotmail dot com
Description:
------------
Firstly, thank you for your hard work, it is appreciated.

It seems filemtime will not accept file paths longer than 256 chars.
I have some long dir names consisting of totally 165 chars, and a file inside it consisting of 94 chars. The script doesnt exit, but i get a warning and a NULL result.

Warning: filemtime() [function.filemtime]: stat failed for [file.php] in [dir] on line #

Reproduce code:
---------------
#$path = string 165 chars
#$file = string of 94 chars

filemtime($path."/".$file); 

Expected result:
----------------
timestamp for file

Actual result:
--------------
NULL

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-12-01 16:31 UTC] jani@php.net
-Status: Open +Status: Assigned -Package: Feature/Change Request +Package: Filesystem function related -Assigned To: +Assigned To: pajoye
 [2011-12-13 15:36 UTC] php at stock-consulting dot com
Apparently, the path length limit exists for other PHP functions as well.

For example, glob() fails to return files when the length of the file name including it's path exceeds 240...260 characters (unsure of the precise limit). There is no warning, it just silently gives the wrong result.

In my case, it's PHP 5.3.6 running as a CLI script on Ubuntu 11.10, the files in question reside on a network share (host: Win7). Shell commands like "ls" display all directory entries correctly, so the OSes appear to work okay.

I tried to change the shell's CWD to the network directory and to run the script there, but the issue remained. Apparently, PHP doesn't consider the current working directory, but the "real path", which remains too long.
 [2013-10-15 12:13 UTC] pajoye@php.net
-Status: Assigned +Status: Not a bug
 [2013-10-15 12:13 UTC] pajoye@php.net
Not a bug, but the 255 path length limit on Windows with ANSI APIs.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Nov 23 11:01:28 2024 UTC