PHP

[function.file-put-contents]: failed to open stream: File name too long

Written by Ian Carnaghan · 15 sec read >

Error: [<a href=’function.file-put-contents’>function.file-put-contents</a>]: failed to open stream: File name too long

To solve this error you need to rename the filename so that the filename and extention together are no more than 255 characters, an easy way to do this is

$filename=substr($name,0,251).'.pdf';

Note, that we used the character count 251 since 251 + the 4 characters for the extention together add up to 255 characters.

Last Updated On March 22, 2018
Written by Ian Carnaghan
I am a software developer and online educator who likes to keep up with all the latest in technology. I also manage cloud infrastructure, continuous monitoring, DevOps processes, security, and continuous integration and deployment. In my spare time I teach undergraduate classes in web development. Profile

Leave a Reply

avatar
  Subscribe  
Notify of