Unable to create file php ошибка

mPDF error: Unable to create output file

I am Using mPDF to generate pdf from an html. On my localhost the pdf is generated to the located directory successfully. But not on Server, although I have open the permissions of that directory.

Found this comment from an answer and changed fopen($file_out,’wb’); to fopen($file_out,’w+’); in mpdf.php But no success. Thanks for any help.

2 Answers 2

Try not to modify the source. Instead, revert back to fopen($file_out,’wb’); and make sure that folder permissions are set to 0777 , like you did.

Also, check if you’re using the absolute path in order to write to a file, rather than using relative paths or even worse, URL.

Having same issue, and file_path i am passing is absolute. still getting the issue.. Unable to create output file: /var/www/path_to_my_file/my_file.pdf

I received the same error message.

The problem for me was that I was saving a file with a filename that had invalid characters.

I created this function to replace invalid characters with usable characters:

// Function to replace disallowed characters from file name. function fixFileName($file_name) < // $file_name = str_replace("\\", "\\", $file_name); $file_name = str_replace("/", " ", $file_name); $file_name = str_replace(">", "\>", $file_name); $file_name = str_replace("

Hope this helps if someone else runs into this issue. I wasn’t sure about the backslash, so I commented it out.

Источник

Читайте также:  Using browser cache javascript
Оцените статью