Reputation: 1029
I have a website that is generating a PDF file based from data.
I tried it in a free webhost and it is ok but when i upload it to my server i get this error:
TCPDF ERROR: Can't open image file: /var/www/html/tcpdf/cache/mska_1d34cb1ba2c1951624fbccb7556c6d1d
in the cache folder the mska_1d34cb1ba2c1951624fbccb7556c6d1d doesnt exist in the folder.
Upvotes: 10
Views: 39550
Reputation: 866
In my case, the file was protected and TCPDF tried to get that image with CURL (!?!?) and it got a 403 error, because Apache did not find the right cookie.
Upvotes: 0
Reputation: 1
I fixed replacing url http://www.example.com/img1.jpg with absolute path of the image /home/image/img1.jpg
Upvotes: -1
Reputation: 8101
Check that your files have extension of pdf (all lower case) and not PDF (all caps). Or make them consistent one way or another. I had this issue between Windows / Linux systems.
Upvotes: 0
Reputation: 11
This issue can also be caused by enforcing SELinux. An exception needs to be added. Can be easily tested with setenforce 0, and then retry to produce the pdf.
Upvotes: 0
Reputation: 1735
In Ubuntu this error was fixed by setting 777 permissions on the tcpdf/cache/
folder:
chmod 777 cache
I tried with 755 or 775 and did not work.
Upvotes: 4
Reputation: 11
just create a folder named cache from the library folders TCPPDF
where there are config folders, fonts and images, also create a cache folders and give permission 777 or 755 if not work.
Upvotes: 1
Reputation: 5107
In addition to Bert's recommendation to check the folder permissions, check for HTTP/HTTPS issues, and note that you can set the K_PATH_MAIN server path to the tcpdf folder if it's not being automatically calculated correctly. (in tcpdf_config.php)
define ('K_PATH_MAIN', '/my/absoulte/path/tcpdf/');
Upvotes: 2
Reputation: 1029
I got the answer now.
For all who will be able to encounter this problem these are the possible solution.
One cause is that folders inside tcpdf has no permissions of write and read. make sure the folder for cache and images has 644 or 755 (recommended) permission. these permission is very important because there is a process when generating pdf it write something is the cache or read into images.
another cause is that tcpdf does not accept png file or with transparent images. my solution was to make the image into a jpeg and apply a white background for it. so avoid png with transparent.
hope it helped.
Upvotes: 14
Reputation: 17710
At a guess (with a name like that), it's trying to WRITE to that folder. Check PHP/Apache has write permissions to that folder.
It'll also want to read from it later as well, so give read and write permissions.
Upvotes: 3