SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Evangelist -Oz-'s Avatar
    Join Date
    Nov 2001
    Location
    Phoenix, AZ, USA
    Posts
    406
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Delete an image using unlink help?!?

    I wrote a script that uploads a jpg image to the server.

    Now I want it to be able to delete the image if the user so desires. The problem is that I can't seem to get unlink to remove the image. I can use unlink to remove a script i post there as long as i chmod the script 777. I can't change the permissions for the image though (as far as i can tell). Can anyone help me here?

    This is what I'm using right now:
    Code:
     unlink ("$rootpath/images/screens/" . $row->THUMB);
     unlink ("$rootpath/images/screens/" . $row->IMAGE);
    Any help would be greatly appreciated.
    Oz
    GamersMark - On Target Gaming
    OzTheory - Programming and Web Solutions
    AmIBlocked - Check if you've been blocked on IM

  2. #2
    SitePoint Evangelist -Oz-'s Avatar
    Join Date
    Nov 2001
    Location
    Phoenix, AZ, USA
    Posts
    406
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    nevermind it is working, please delete this.
    Oz
    GamersMark - On Target Gaming
    OzTheory - Programming and Web Solutions
    AmIBlocked - Check if you've been blocked on IM

  3. #3
    SitePoint Enthusiast lacerus's Avatar
    Join Date
    Aug 2003
    Location
    Hamburg
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you should do
    Code:
    if( is_file( "$rootpath/images/screens/" . $row->THUMB ) ) {
        unlink(...);
    }
    Because if the db cell is empty, PHP would attempt to unlink a directory and give an error

  4. #4
    SitePoint Evangelist -Oz-'s Avatar
    Join Date
    Nov 2001
    Location
    Phoenix, AZ, USA
    Posts
    406
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks, i will add that in
    Oz
    GamersMark - On Target Gaming
    OzTheory - Programming and Web Solutions
    AmIBlocked - Check if you've been blocked on IM


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
  •