Page 1 of 1
Problem with unlink..
Posted: Thu Aug 14, 2003 12:28 am
by sghetti
I've been trying to get this to work for some time and now that my brain is mush I feel it's time to go to the experts. I have a php generated page that displays all of the files from a users directory. Beside the file names is a "Delete" link that SHOULD delete the file it is next to when clicked. However, as soon as the page loads ALL of the files get deleted. What is the best way to go about this?
Posted: Thu Aug 14, 2003 2:33 am
by Tubbietoeter
post your code please
Posted: Thu Aug 14, 2003 8:58 pm
by sghetti
The link looks like this:
And the script is just this:
Code: Select all
<?php
session_start();
header("Cache-control: private");
unlink($file);
?>
I have absolutely no idea how to do this. Obvious from the code I'm sure, but I always try it myself before asking. Thanks for any help.
Posted: Thu Aug 14, 2003 9:54 pm
by Drachlen
Paste the code to the page which lists the files with the delete button along side
Posted: Thu Aug 14, 2003 10:08 pm
by sghetti
Hey! I got it! had to do this with the link:
<a href="delete.php?file=<?php echo $file; ?>">Delete</a>
I wasn't giving the script a way to know what file the variable $file, corresponded to. Dang, I'm dumb.

Thanks for at least wanting to help though.