HI
I am trying to do the following:

I have an ftp server configured, but instead of the user having to use
an ftp client, I'd like them to use the browser: So I'm trying to make a
mini web-based ftp client. Idea is to get their username and password (
and maybe the ftp address as well?) and to then have php log into the
server and list the contents of the folder (no need to handel subfolders
etc.). Then I would want them to be able to click on the file to
download it.

I have done the first part with no problem as per below:

<?php
$ftp_server = "192.168.0.23";
$ftp_user_name = "test1";
$ftp_user_pass = "test1";
// 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<br>";
        die;
    } else {
        echo "Connected to $ftp_server, for user $ftp_user_name<br>";
    }

// get dir listing
$file_list = ftp_nlist($conn_id,"");

foreach ($file_list as $num=>$val) {
        echo "<br><a
href=\"download_ftp.php?user=$ftp_user_name&pass=$ftp_user_pass&file=$val\">$val</a> 
<br>";
}

ftp_close($conn_id);
?>


But I am baffeled for the rest, ie, what to do on the download.ftp page.
First I tried the ftp_get() with the $file used as the local and remote
files, but it seems that that will not download the file to the client
machine, but rather to the server itself.
So, how can I have the file download to the client's machine ( ps, the
files are NOT inside a webfolder, so I cannot simply make links to them,
and yes, it is done for security reasons; basically I am trusting/using
vsftp's security instead of having to devise my own method..)

Please point out my obvious lack in knowledge of these matters.

Thanks





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to