SitePoint Sponsor

User Tag List

Results 1 to 9 of 9

Hybrid View

  1. #1
    SitePoint Wizard
    Join Date
    Dec 2004
    Location
    At My Desk!!
    Posts
    1,642
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Warning when using Unlink!

    I am trying to delete a file and am getting this error message

    Warning: unlink(Includes/Modules/News_Manager) [function.unlink]: Is a directory in /home/hvknuamn/public_html/mainbuild/Includes/Modules/Module_Manager/Module_Functions.php on line 35

    This directory is the place I am calling the unlink function from, I dont understand why im getting this. Any ideas?

    Thanks in advance

    p.s the file has correct permissions to delete and im not getting file not found, so it cant be that
    "Am I the only one doing ASP.NET in Delphi(Pascal)?"

  2. #2
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,807
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    afternoon

    The script thinks you are trying to delete an entire directory, post your script...
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  3. #3
    SitePoint Wizard
    Join Date
    Dec 2004
    Location
    At My Desk!!
    Posts
    1,642
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hiya Mate,

    I am

    PHP Code:
    $filetodelete "Includes/Modules/" $deleteid "_Manager";
    unlink($filetodelete); 
    $deleteid in this case is News
    "Am I the only one doing ASP.NET in Delphi(Pascal)?"

  4. #4
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,807
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    Is the News_Manager an actual file?
    As it is the script is still assuming it's a directory called News_Manager.

    You might be able to put a condition in using is_file() to check the file first.
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  5. #5
    SitePoint Wizard
    Join Date
    Dec 2004
    Location
    At My Desk!!
    Posts
    1,642
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No its a directory. I want to just delete that folder and its contents
    "Am I the only one doing ASP.NET in Delphi(Pascal)?"

  6. #6
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Or if you are actually trying to delete the directory, use rmdir. Just make sure it is empty before you do.
    Saul

  7. #7
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,807
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    then do what php_daemon said
    Youwill probably need to iterate through the dir first and delete the files and then delete the folder
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  8. #8
    SitePoint Wizard
    Join Date
    Dec 2004
    Location
    At My Desk!!
    Posts
    1,642
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeh, thanks guys, I used this in the end:
    PHP Code:
    foreach (glob("Includes/Modules/" $deleteid "_Manager/*.*") as $filetodelete) {

        
    unlink($filetodelete);

    }
            
    $dirtodelete "Includes/Modules/" $deleteid "_Manager";
    rmdir($dirtodelete); 
    "Am I the only one doing ASP.NET in Delphi(Pascal)?"

  9. #9
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,807
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    looks good to me! glad you got it sorted
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....


Bookmarks

Posting Permissions

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