我正在使用Tcpdf模块和PHP从订购系统创建动态PDF发票.
然后,该脚本应将发票保存到名为"发票"的文件夹中.该文件夹存在,并且"everyone"(Windows)具有完全权限.
我使用的代码是这样的:
$pdf->Output('invoices/Delivery Note.pdf', 'F');
Run Code Online (Sandbox Code Playgroud)
这使用fopen来保存文件.
但是我得到的错误是: Warning: fopen(): remote host file access not supported, file://invoices/Delivery Note.pdf
这是一个本地文件,而不是远程文件.
我尝试添加这样的/前缀:
$pdf->Output('/invoices/Delivery Note.pdf', 'F');
Run Code Online (Sandbox Code Playgroud)
但后来我得到了这个错误: Warning: fopen(file:///invoices/Delivery Note.pdf): failed to open stream: No such file or directory
我创建了该文件,并将其留空,但与上面的错误相同.
有谁知道我为什么会收到这个错误?
Ger*_*erd 27
从php-Script您可以使用:
$pdf->Output(__DIR__ . '/invoices/Delivery Note.pdf', 'F');
Run Code Online (Sandbox Code Playgroud)
小智 7
升级到vtiger 6.2中的tcpdf 6.2.6之后,我遇到了同样的问题,用pdf发送电子邮件.
所以我更改了文件:
libraries/tcpdf/include/tcpdf_static.php
Run Code Online (Sandbox Code Playgroud)
我在fopenLocal()中注释了代码并更改了该行
fopen($_SERVER['DOCUMENT_ROOT'].$filename, $mode);
Run Code Online (Sandbox Code Playgroud)
看到:
/**
* Wrapper to use fopen only with local files
* @param filename (string) Name of the file to open
* @param $mode (string)
* @return Returns a file pointer resource on success, or FALSE on error.
* @public static
*/
public static function fopenLocal($filename, $mode) {
// if (strpos($filename, '://') === false) {
// $filename = 'file://'.$filename;
// } elseif (strpos($filename, 'file://') !== 0) {
// return false;
// }
return fopen($_SERVER['DOCUMENT_ROOT'].$filename, $mode);
}
Run Code Online (Sandbox Code Playgroud)
改变之后,它起作用了.
类似于user1007017,但只需注释如下所示的行(tcpdf 6.2.11)
public static function fopenLocal($filename, $mode) {
if (strpos($filename, '://') === false) {
//$filename = 'file://'.$filename;
} elseif (stream_is_local($filename) !== true) {
return false;
}
return fopen($filename, $mode);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
21331 次 |
| 最近记录: |