简体   繁体   English

使用 tcpdf、php 7 和 drupal 7 显示图像时出现 tempnam() 错误

[英]tempnam() error in when display images using tcpdf, php 7 and drupal 7

We are getting below error when generating pdf file using tcpdf in drupal 7.在 drupal 7 中使用 tcpdf 生成 pdf 文件时,我们遇到以下错误。

Notice: tempnam(): file created in the system's temporary directory in TCPDF_STATIC::getObjFilename() (line 296 of /var/www/html/sites/all/libraries/tcpdf/include/tcpdf_static.php).

When we commenting the below code, this error will disappear当我们注释下面的代码时,这个错误就会消失

$path = 'sites/default/files/'.$user->mail.'/'.$sign_file;
   $tcpdf->Image($path,145, 102.75, 40, 15, $sign_filetype , '', '', true, 150, '', false, false, 1, false, false, false);

File permissions of this file is这个文件的文件权限是

-rw-rw---- 1 apache apache 5917 Mar  4 23:10 sign.png

Version details are TCPDF module - 7.x-1.0-beta1 and php 7.2.27.版本详细信息是 TCPDF 模块 - 7.x-1.0-beta1 和 php 7.2.27。 Thanks in advance for any suggestion to resolve this issue.预先感谢您提供解决此问题的任何建议。

This can be solved by adding the path of temp directory in php.ini file.这可以通过在php.ini 文件中添加temp 目录的路径来解决。 Eg:例如:

upload_tmp_dir = /tmp

Just came across the same problem today, I was able to resolve it without going to the php.ini今天刚遇到同样的问题,我不用去php.ini就可以解决它

in tcpdf_lib\\config\\tcpdf_config.phptcpdf_lib\\config\\tcpdf_config.php

define ('K_PATH_CACHE', '/mypath/tcpdf_lib/cache');

Was set, but there was no cache directory.已设置,但没有缓存目录。 Creating one with appropriate permissions correct the PHP notice.创建一个具有适当权限的更正 PHP 通知。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM