TCPDF ERROR: unable to open image file: / var / www / html / tcpdf / cache /

I have a website that creates a data-based PDF file.

I tried this in free web hosting, and that’s fine, but when I upload it to my server, I get this error:

TCPDF ERROR: cannot open image file: / var / www / html / tcpdf / cache / mska_1d34cb1ba2c1951624fbccb7556c6d1d

in the cache folder, mska_1d34cb1ba2c1951624fbccb7556c6d1d does not exist in the folder.

+7
source share
9 answers

Now I got the answer.

For anyone who can run into this problem, this is a possible solution.

One of the reasons is that the folders inside tcpdf do not have write or read permissions. make sure the cache and image folder has a resolution of 644 or 755 (recommended). This permission is very important because there is a process when creating a pdf file that writes something in the cache or reads images.

Another reason is that tcpdf does not accept png file or with transparent images. my solution was to make the image in jpeg and apply a white background to it. so avoid png with transparent.

hope this helps.

+12
source

On Ubuntu, this error was fixed by setting 777 permissions in the tcpdf/cache/ folder:

 chmod 777 cache 

I tried with 755 or 775 and did not work.

+3
source

Guess (with that name) trying to WRITE to this folder. Verify that PHP / Apache has write permissions to this folder.

He will also want to read it later, so give permission to read and write.

+2
source

In addition to Bert’s recommendation for checking folder permissions, check for HTTP / HTTPS problems and note that you can set the K_PATH_MAIN server path to the tcpdf folder if it is not automatically calculated correctly. (in tcpdf_config.php)

define ('K_PATH_MAIN', '/my/absoulte/path/tcpdf/');

+2
source

just create a folder called cache from the TCPPDF library folders

where there are configuration folders, fonts and images, also create cache folders and give permission 777 or 755 if they do not work.

+1
source

This problem can also be caused by SELinux forcing. An exception must be added. You can easily test with setenforce 0 and then try again to create pdf.

0
source

Make sure your files have the pdf extension (all lowercase) and not the pdf (all caps). Or make them consistent anyway. I had this problem between Windows / Linux systems.

0
source

In my case, the file was protected, and TCPDF tried to get this image using CURL (!?!?), And it got a 403 error because Apache did not find the correct cookie.

0
source

I fixed the url replacement http://www.example.com/img1.jpg with the absolute image path / home / image / img1.jpg

-one
source

All Articles