PHP Warning: failed to open stream: File name too long

Message:

PHP Warning: fopen(cache/____________.cache): failed to open stream: File name too long in test.php on line 12

Error type: warning

Symptoms:

Call to function fopen() fails for some files.

Cause:

The file system has a limit for the file names, for Linux (ext) is 256 characters, trying to create a file longer than that will fail and issue the warning above.

Fix:

Shorten the filename to have less than 256 characters. Use hash functions if you can’t just truncate the file name.

Leave a Reply

Your email address will not be published. Required fields are marked *

Security question: * Time limit is exhausted. Please reload the CAPTCHA.