Php – TCPDF cant image because it is using a wrong directory path

pdfPHPtcpdf

I get my images in my pdf document on my localhost but on the production site i get the error TCPDF ERROR: [Image] Unable to get image i am using an html img tag to get the images and the src is the directory path to this image not a url, but i found out that TCPDF is adding the path i give it with the path to my www folder like:

path to picture i give to tcpdf: home/inc_dir/img/pic.jpg
tcpdf looks for it here: home/www/home/inc_dir/pic.jpg

can someone please help me find out tcpdf is concatenating the directories?

Best Answer

You can also change only the image path instead of main path use:

define('K_PATH_IMAGES', '/path/to/images/');
require_once('tcpdf.php');

This won't break fonts/ and other tcpdf paths.