本文介绍了使用https时的TCPDF缓存问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一段时间以来,我们一直在使用TCPDF即时创建PDF,并且一切正常。

We have been using TCPDF to create PDFs on the fly for a while now and everything has been working fine.

但是,我们今天使用以下内容更改为https htaccess代码:

However, we changed to https today using the following htaccess code:

RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://www.berau.at/$1 [R,L]

现在,我们收到以下TCPDF错误:

Now we are getting the following TCPDF error:

TCPDF ERROR: [Image] Unable to get image: /home/.sites/64/site1783/web/pdf2/cache/img_UgqqR0

如果我们删除https的htaccess重定向,一切都会恢复正常。

If we remove the htaccess redirect for https, everything works fine again.

我们已经搜索了TCPDF网站,但是那里没有提到https问题。

We've searched the TCPDF website, but no references to https problems there.

TCPDF缓存文件夹已经具有755权限!

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);

在此先感谢您的帮助!

推荐答案

以下是解决我们问题的方法:

Here's the solution to our problem:

tcpdf.php中的第23847行包含对http的直接引用。将此行从

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'];
                    }

if (preg_match('%^/{2}%', $tag['attribute']['src'])) {
                        $tag['attribute']['src'] = 'https:'.$tag['attribute']['src'];
                    }

一切正常。

这篇关于使用https时的TCPDF缓存问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 16:34