View Full Version : Settings files to expire

04-20-2003, 09:50 PM
If a file in created using fopen, how can I set it so the file will expire, ie. delete itself after a specified amount of days ?

04-20-2003, 11:35 PM
It cannot be done automatically with PHP. You would need to use a CRON job which is basically a linux scheduling program. You can set it up to run every XX seconds/minutes/days etc. It will execute any command you tell it to at that time which can be a shell script or a php script.

04-21-2003, 10:53 AM
You cannot set an expire, but something I have done before (using a database too), is to get the time when the file was created, and add an ammount of time onto the file. ( say 3600, an hour ), and insert that value into a database, along with the filename.

Providing anyone visits your web page, you check the current time against the time in the db, if the current time is greater, you delete the file with the filename from the db.

If you want more help, post back.