Function help. Rep awarded.

Discussion in 'PHP' started by Josh-H, Sep 9, 2007.

  1. #1
    I have a function that deletes the files chosen by the user, but if its a directory and has files in it it doesn't work. Is there a way to loop through and unlink every file before removing the directory?

    All help appreciated.
     
    Josh-H, Sep 9, 2007 IP
  2. crazyryan

    crazyryan Well-Known Member

    Messages:
    3,087
    Likes Received:
    165
    Best Answers:
    0
    Trophy Points:
    175
    #2
    Can I see the function code
     
    crazyryan, Sep 9, 2007 IP
  3. m0nkeymafia

    m0nkeymafia Well-Known Member

    Messages:
    399
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    125
    #3
    If its a directory use the php function readdir and thatll return a list of files in that directory, use a while loop to go round each one deleting the files, then carry on with deleting any other files you need
     
    m0nkeymafia, Sep 9, 2007 IP