SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Apr 2011
    0 Post(s)
    0 Thread(s)

    Delete thumbnail and regular images from folder using php

    I don't know very much about php, but does anyone know how to delete images and also to download them to the computer when the user selects it?

    The images are located in my folder/directory. Also, I want to delete both the thumbnail and the regular image.

    I'm really new to php so this is still rather confusing. I have seen forums saying to use the unlink function, but I don't really know how to implement that into my code. Does it go into the upload and resize code? or does it have its own page? If possible, give me an example

    Thank you

  2. #2
    SitePoint Addict svcghost's Avatar
    Join Date
    Oct 2010
    0 Post(s)
    0 Thread(s)
    First you should probably give us your code so we can understand what you're trying to do and how you're getting it done so far.

    You say you want to use PHP to delete a file in a directory on your web server?
    Here is a simple usage of the unlink() function that accomplishes that:
    // delete.php
    For this script, the php file that this code is in must reside in the same folder as the file you want to delete. Let us delete a file called test.html. In this case, whatever directory delete.php and test.html are in, test.html will be deleted from that directory.

    Now. Are you trying to delete a file when a user clicks a button or something? Please provide more info so we can further help.

  3. #3
    SitePoint Mentor silver trophy
    Rubble's Avatar
    Join Date
    Dec 2005
    Cambridge, England
    82 Post(s)
    3 Thread(s)
    As you say to delete a photo use unlink. Basicaly you need to feed the name and location of the image to delete. This can be done via a form of some sort using direct filename input or a table with check boxs.

    PHP Code:
    // Image name from a form
    $delete 'image to delete';
    // Delete the images
    I am not sure how to download an image using php but if the image is open on the screen the user can click on it and use "Save as" ?


Posting Permissions

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