SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2008
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    images delete from folder

    Hi,

    I want to delete images from my table as well as my image folder. I know how to delete from table.

    I want to know how to delete image from folder.

    Can anyone explain.

    Thanks in advance.

  2. #2
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    See unlink().

    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  3. #3
    SitePoint Enthusiast
    Join Date
    Nov 2008
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks. But I need...

    i.e I have 4 records. Each record contains 2 images. Now I want to delete only one record from my table and my image folder(specific images).

  4. #4
    SitePoint Addict
    Join Date
    Jul 2008
    Posts
    213
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    To delete a folder you would use the rmdir() function. However you would have to empty the directory first by using unlink() as mentioned.

  5. #5
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    First delete the record from the database, then unlink() the file name that corresponds to the record you deleted. You may need to first query database to get the filename before you actually delete the database record.

  6. #6
    SitePoint Zealot
    Join Date
    Apr 2009
    Location
    South Florida
    Posts
    187
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you need to write a small PHP function to recursively delete all your images using unlink(). Ones you delete all the files in the folder, you can use rmdir() function to remove folder.


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
  •