TCPDF cache problems when using https

巧了我就是萌 提交于 2020-01-05 04:22:05

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!