/    Sign up×
Community /Pin to ProfileBookmark

Make ftp files a download link

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 />’;
}
[/CODE]

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”;
}

[/CODE]

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @waMP spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...