Click a link, Delete a File

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
VKX
Forum Commoner
Posts: 41
Joined: Mon Oct 03, 2005 1:43 pm

Click a link, Delete a File

Post by VKX »

I would like to be able to click a link that's automatically generated for me, and have it delete a file. The link would probably call a php page that would feed the filename into a function I'm assuming. What kind of function would I need to create to do that?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

create a list of files using opendir() and readdir(). Then pass the filename as a $_GET parameter along withfile_exists() to make sure the file exists before using unlink() to delete the file
Post Reply