Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TCPDF save pdf to /tmp/ (or whatever the system default for temp files are)

Tags:

php

tcpdf

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:

  1. The application doesn't have to have a publicly writable folder
  2. 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?

like image 262
Chris Muench Avatar asked Dec 27 '22 21:12

Chris Muench


1 Answers

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.

And you know, just pass that as parameter to your save function $TCPDF->Output("$tmp/file.pdf", "F");

like image 171
mario Avatar answered Dec 30 '22 10:12

mario