View Full Version : click a link to delete a file?
05-22-2004, 03:42 AM
I'm trying to create a link, so when the user clicks the link it will delete a file from a directory.
I've been messing around with the unload command with no success.
This is so a member can download a text database file. Then I need them to click the delete database link so that the database file gets deleted, so when new information is sent, a new database is created.
All I need to know is how to delete a file from my server by clicking a link.
05-22-2004, 03:45 AM
unlink is used to delete files - you could create a small script that deletes a file (unlinks) using a variable that is passed via the link.
ie link to deleteme.php --- pass variable/filename --- deletme.php takes the variable and deletes the file - then returns to the calling page
05-22-2004, 10:24 PM
<form action="delete.php" method="post">
<b>Name of file(on the server):</b><INPUT type='text' Name='file'><Br>
<INPUT type='Submit' Name='filed' Value='Delete File'>
Now the php:
that's pretty easy...
easy ... but i think he asked for a delete-link. So then you just display the filename as a link with the name in the querystring. Like
<a href="removefile.php?file=test.php" title="Delete file 'test.php' from the server">test.php</a>
and then inside removefile.php, you'll have
but this is realy risky business because it would be very easy to manupulate the querystring to remove whatever files you want (like *.* or so), so you need to do some extra testing to see if the querystring isn't manipulated
05-23-2004, 02:48 AM
Actually I will probably make use of both your examples.
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.