Is there a way to delete a file within a directory using a link?
I have a script that will list all the files in a directory and, in the output, I'd like to create a link next to each file that says "Delete This file"
filename1.jpg Delete File
filename2.jpg Delete File
filename3.jpg Delete File
filename4.jpg Delete File
Any help appreciated.
Thanks in advance.
mc
Can files be deleted using a link?
Moderator: General Moderators
- jayshields
- DevNet Resident
- Posts: 1912
- Joined: Mon Aug 22, 2005 12:11 pm
- Location: Leeds/Manchester, England
Maybe we should give a reason why:feyd wrote:yes, they can.. however, it's suggest to not allow deletions via a standard link, but by having that link perform a submission (post) to a script that can perform the deletion instead.
say your deletion url is http://127.0.0.1/admin/delete.php?id=56
now only an admin with the correct password could cause the file to be deleted by going to that url, but lets say someone used bbcode on this forum to put an image with that as the source. If an admin were to log into your application, and then visit this forum, when his computer tries to load the image tag is requests the deletion URL. There are other workarounds to using POST, but that has been discussed in great lengths in other threads.