Reply to Re: Strategy for creating files and then cleaning up

Your name:

Reply:


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

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация