Page 1 of 1

Unlink - file deletion

Posted: Thu Jan 27, 2005 8:02 am
by snicolas
Hi,

I am creating some fynamic pdf in the root folder.
I have a script that i can run manually to delete all ".pdf" files.
I would like this script to run automatically when creating the pdf. and delete the files (pdf) older than 1 hour....
How can i do this?

Code: Select all

<?php

foreach (glob("*.pdf") as $filename) {
   echo "$filename size " . filesize($filename) . "\n";
   unlink($filename);
}

?>
thanks

s

Posted: Thu Jan 27, 2005 8:16 am
by rehfeld

Code: Select all

if ((time() - 3600) > filemtime($filename)) &#123;
    unlink($filename);
&#125;

Posted: Thu Jan 27, 2005 8:31 am
by snicolas
Thanks rehfeld, worked perfectly....

I was testing the creation of pdf and automatic deletion..now this works...
My ultimate goal is to be able to post information from a form and insert these information into a template pdf...
I had a look at fpdi, but it's not really clear...
Does anybody have a proper example, with a form?

Thanks again for the help.

s