Im trying to display some files in a web page so the user can download it, i display the files correctly but the link href is not working, instead of download the file, the browser try to display the file in the browser and send :
Not Found
The requested URL /public_html/Factura.pdf was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
$connect = ftp_connect("xxx.org");
$result = ftp_login($connect, "xxx", "xxx");
$a = ftp_nlist($connect, "./public_html/");
foreach($a as $value){
echo '<a href="'.$value.'">'.basename($value).'</a> <BR>';
}
how can i accomplish that?
thanks!
You can use the basename() function on the path, this will give you the filename:
Edit:
If the files are local it would be faster to just glob() or opendir() the directory, im assuming your goal is to use this script on a remote server so I would also suggest you include the url to the hosting server.