Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Location
    England
    Posts
    172
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Settings files to expire

    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 ?
    \o/

  • #2
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,280
    Thanks
    4
    Thanked 83 Times in 82 Posts
    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.
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #3
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •