Auto delete old file

Discussion in 'PHP' started by sg552, Sep 20, 2008.

  1. #1
    Hi,

    Anyone know php code to delete old file. I have old file in this cache directory /public_html/cache/ .

    I know maybe the best way is using cron, I know how to setup cron in cpanel but I don't know the php code.

    Any idea :confused:
    Thanks in advance :)
     
    sg552, Sep 20, 2008 IP
  2. JAY6390

    JAY6390 Peon

    Messages:
    918
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #2
    as in you want a function to delete files? use unlink()
     
    JAY6390, Sep 20, 2008 IP
  3. Bohra

    Bohra Prominent Member

    Messages:
    12,573
    Likes Received:
    537
    Best Answers:
    0
    Trophy Points:
    310
    #3
    Use the code to list the files and use unlink() to delete it
     
    Bohra, Sep 20, 2008 IP
    sg552 likes this.
  4. sg552

    sg552 Peon

    Messages:
    187
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Yes it's works :) but need to chmod my cache directory to 777 :/

    Thanks to both of you :)

    p/s: When I try to give rep to you jay6390 this forum say I need to spread some reputation before I can add to you again... but MegaMania have no problem. Maybe I give Jay rep too much :p
     
    sg552, Sep 20, 2008 IP
  5. JAY6390

    JAY6390 Peon

    Messages:
    918
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #5
    lol its fine sg. I can't say I'm all that fussed with rep :p
     
    JAY6390, Sep 20, 2008 IP