问题
We have been using TCPDF to create PDFs on the fly for a while now and everything has been working fine.
However, we changed to https today using the following htaccess code:
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.berau.at/$1 [R,L]
Now we are getting the following TCPDF error:
TCPDF ERROR: [Image] Unable to get image: /home/.sites/64/site1783/web/pdf2/cache/img_UgqqR0
If we remove the htaccess redirect for https, everything works fine again.
We've searched the TCPDF website, but no references to https problems there.
The TCPDF cache folder already has 755 permissions!
Here's the code we're using to call the image:
$img_file = $rs_produkt[20];
$pdf->Image($img_file, 0, 0, 0, 0, '', '', '', false, 300, '', false, false, 0);
Thanks in advance for any help!
回答1:
Here's the solution to our problem:
Line 23847 in tcpdf.php contains a direct reference to http. Change this line from
if (preg_match('%^/{2}%', $tag['attribute']['src'])) {
$tag['attribute']['src'] = 'http:'.$tag['attribute']['src'];
}
to
if (preg_match('%^/{2}%', $tag['attribute']['src'])) {
$tag['attribute']['src'] = 'https:'.$tag['attribute']['src'];
}
and everything works fine.
来源:https://stackoverflow.com/questions/43040804/tcpdf-cache-problems-when-using-https