|
Posted by Erwin Moller on 07/03/06 16:20
laredotornado@zipmail.com wrote:
> Hi,
>
> I'm using PHP 4.3. There is a section of my application in which I'd
> like users to be able to download a custom file. The file would be
> different for each user, so I was planning on creating it on the fly
> when they click "Download". However, I would like to delete the file
> from the server a certain period of time after they've downloaded it.
> (It's a 3 or 4K file). How can I do this?
>
> Thanks, - Dave
Hi Dave,
This can be done in several way, but why do you actually create the file?
You can also just give the user the experience there is a file when (s)he
clicks the downloadbutton.
Just let the download-php-script produce the output, just as you do before
writing the file, and deliver that.
If that doesn't work for you for some reason, and you absolutely need to
create a real file, you can do several things to clean them up, the most
easy:
- Create a sheduled job (cron on *nix) that checks all possible files and
check their createdate. If too old, delete.
Alternatively to a sheduled job, you could use an approach that will do this
once every 100 times your function is called that creates the file.
Or every time, but this may get slow if you have a great numbers of files.
Regards,
Erwin Moller
Navigation:
[Reply to this message]
|