SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2006
    Posts
    70
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    deleting image as well, not only the record

    Hi

    On my website, I have added the possibility for the users to upload their photos. I do have a back office from where I can delete some of the images that do not comply with the site policy.

    However, I am deleting only the record from the database, not the actual image from the folder where it is uploaded.

    Record in the database field look like 150068imagename.jpg for example. I do have added time stamp to each image to prevent duplicate images names.

    What I would like to accomplish is not only to delete the record, but to delete and the actual file from the folder which is located on the server where the site is hosted. Anyone can tell me if and how can I accomplish this?

    Regards, Zoreli

  2. #2
    Utopia, Inc. silver trophy
    ScallioXTX's Avatar
    Join Date
    Aug 2008
    Location
    The Netherlands
    Posts
    9,067
    Mentioned
    153 Post(s)
    Tagged
    2 Thread(s)
    You can use the unlink function to delete files from the hard disk. Just execute that once you've removed the row from the database (not before, because then if the deletion of the row fails you're in a situation where you have a row pointing to an image that does not exist, which may cause nasty errors on your website).
    Rémon - Hosting Advisor

    SitePoint forums will switch to Discourse soon! Make sure you're ready for it!

    Minimal Bookmarks Tree
    My Google Chrome extension: browsing bookmarks made easy

  3. #3
    SitePoint Enthusiast
    Join Date
    Jul 2006
    Posts
    70
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks mate...I will give it a try, hopefully it will work...

    Regards, Zoreli


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
  •