Click to See Complete Forum and Search --> : Get the link text
thtang
December 11th, 2008, 10:31 AM
Hi, I have loaded the whole file directory of a folder. and show the file name as a link. I would like do a delete function. When the user click the file name, it will trigger a php function to do the file delete.
However, I dont know how to get the file name that the user have clicked. Could you give me some advices on this?
Thank you.
PeejAvery
December 15th, 2008, 08:28 AM
You are already creating a link to the file, but yet you can't get the filename? You're not making any sense.
Thread1
December 16th, 2008, 05:18 AM
^lol
echo "<a href=\"delete.php?file=$filename&folder=$folder\">$filename</a>";
thtang
December 18th, 2008, 12:00 AM
Sorry, maybe I make my question clearer first.
I will display all the files in the folder /downloads
#echo the files
foreach ($files as $file) {
if ($file != "." && $file!= ".."){
echo "<a href=fileManager.php?filename=$file>$file</a><br />";
}
}
and there is a textbox (for displaying the selected file) and a delete button(after clicking it, the file displayed in the textbox will be deleted)
My problem is how to put the filename to the textbox when the user click on the link.
It works for filename with no space. However, it doesnt work for the one with space.
Any advice for solving the problem?
Thank you.
PeejAvery
December 18th, 2008, 08:35 AM
There will be no output difference between a textbox and a line. Just use the onclick event to redirect.
As for the spaces, replace them with %20.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.