I am connecting to a ftp server, and displaying the files in a certain directory on a web page. This all works fine, but I need to make each of the zip files that display, a link for the user to download.
This line displays the zip files, but doesn’t do anything when user clicks on them to download the file
[CODE]
foreach($contents as $c) {
echo ‘<a href=”C:\Server\SN12345\’.$c.'”>’.$c.'</a><br />’;
}
Can someone explain how to make these links work, please?
Below is all my code, minus ip, un and pw in connection. It connects to C: drive
[CODE]
// set up basic connection
$conn_id = ftp_connect($ftp_server);
// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
// check connection
if ((!$conn_id) || (!$login_result)) {
echo “FTP connection has failed!”;
//echo “Attempted to connect to $ftp_server for user $ftp_user_name”;
exit;
} else {
echo “Connected to $ftp_server, for user $ftp_user_name <br>”;
//change the directory
if (ftp_chdir($conn_id, “ServerSN12345”)) {
// get contents of the current directory
$contents = ftp_nlist($conn_id, “.”);
foreach($contents as $c) {
echo ‘<a href=”C:\Server\SN12345\’.$c.'”>’.$c.'</a><br />’;
}
} else {
echo “Couldn’t change directoryn”;
}