I use dompdf to create and send a PDF file to my mail and at the same time save the .txt version on the server. Saving a file works as it should, but it’s not easy for them to force it to save it with a unique name. In this case, I wanted something like date-time.txt (09/06/2012_11: 43.txt)
or even better if it can have a name from the "refnr" text box as a name.
<label for="refnr"><b>Referensnummer:</b></label>
<input type="text" name="refnr" id="refnr" class="input" />
The code is as follows:
$html = '/html.php';
$filename = $dir.'/Admin/files/"date here".txt';
$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->set_paper('a4', 'portrait');
$dompdf->render();
file_put_contents($filename, $dompdf->output());
I tried to play with $name='myfile_'.date('m-d-Y_hia)';, but could not do the job, it just threw an error in this line every time. So now I'm here to seek guidance from you smart people :)
source
share