
May 29th, 2002, 01:52 PM
|
|
Registered User
|
|
Join Date: Feb 2002
Location: The Netherlands
Posts: 19
Time spent in forums: 1 h 9 m 43 sec
Reputation Power: 0
|
|
|
download files using ftp and php
Hi,
I want to download files from a ftp server using a php script with ftp_get(). Is it possible to download files from a server using a script with ftp_get. I mean are the files saved on the users computer or on the webserver? I want to use this script on computers that are behind a firewall that only alows access to the internet on port 80 and the http protocol.
I've got this:
PHP Code:
<?php
// set up basic connection
$conn_id = ftp_connect($server);
// login with username and password
$login_result = ftp_login($conn_id, $naam, $w8);
// check connection
if ((!$conn_id) || (!$login_result)) {
echo "Ftp connection has failed!";
echo "Attempted to connect to $ftp_server for user $ftp_user_name";
die;
} else {
echo "Connected to $ftp_server, for user $ftp_user_name";
}
// upload the file
$upload = ftp_get($conn_id, $naar, $bestand, FTP_BINARY);
// check upload status
if (!$upload) {
echo "Ftp download has failed!";
} else {
echo "Download $bestand from $server as $naar";
}
// close the FTP stream
ftp_close($conn_id);
?>
Thanks,
Sebastiaan
|