php TCPDF 将 pdf 保存到 /tmp/(或任何系统默认的临时文件)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5756740/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
TCPDF save pdf to /tmp/ (or whatever the system default for temp files are)
提问by Chris Muench
When a files is upload via a form its location is somewhere that is writable by the webserver but NOT in the current application folder. The reason I like this is:
当文件通过表单上传时,它的位置是网络服务器可写的位置,但不在当前应用程序文件夹中。我喜欢这个的原因是:
- The application doesn't have to have a publicly writable folder
- If you only need it temporally (such as attaching to an e-mail) then this is a great location
- 应用程序不必具有可公开写入的文件夹
- 如果您只是暂时需要它(例如附加到电子邮件),那么这是一个很好的位置
Is there a way to have access to this location via TCPDF when saving a file?
保存文件时,有没有办法通过 TCPDF 访问此位置?
回答by mario
If you want to use the very same location where uploads end up:
如果您想使用上传结束的相同位置:
$tmp = ini_get('upload_tmp_dir');
But you should use sys_get_temp_dir()
and just '/tmp'
as fallback anyway.
但是无论如何你都应该使用sys_get_temp_dir()
and'/tmp'
作为后备。
And you know, just pass that as parameter to your save function $TCPDF->Output("$tmp/file.pdf", "F");
你知道,只需将它作为参数传递给你的保存函数 $TCPDF->Output("$tmp/file.pdf", "F");