-
Get the link text
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.
-
Re: Get the link text
You are already creating a link to the file, but yet you can't get the filename? You're not making any sense.
-
Re: Get the link text
^lol
Code:
echo "<a href=\"delete.php?file=$filename&folder=$folder\">$filename</a>";
-
Re: Get the link text
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.
-
Re: Get the link text
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.