简体   繁体   中英

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.

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. 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. Eg:

upload_tmp_dir = /tmp

Just came across the same problem today, I was able to resolve it without going to the php.ini

in tcpdf_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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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