Hello serve all friends
Friends, does anyone know how to download files from ftp to php?
For example
test/file.zip
How to download this file with ftp
Hello serve all friends
Friends, does anyone know how to download files from ftp to php?
For example
test/file.zip
How to download this file with ftp
First you need to go to your php.ini
file and add this --enable-ftp
Second Set Up connection and Download your file
<?php
$ftp_server = "ftp.example.com";
// set up a connection or die
$ftp = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server");
// define some variables
$local_file = 'local.zip';
$server_file = 'server.zip';
// set up basic connection
// login with username and password
$login_result = ftp_login($ftp, $ftp_user_name, $ftp_user_pass);
// try to download $server_file and save to $local_file
if (ftp_get($ftp, $local_file, $server_file, FTP_BINARY)) {
echo "Successfully written to $local_file\n";
} else {
echo "There was a problem\n";
}
// close the connection
ftp_close($ftp);
?>