Categories : PHP

PHP FTP File Download Example

// define some variables

$server_file = 'file.xml';
$ftp_server = "server_address";
$ftp_user_name = "user";
$ftp_user_pass = "pass";

$data = file_get_contents('ftp://'.$ftp_user_name.':'.$ftp_user_pass.'@'.$ftp_server.'/' . $server_file);

// put downloaded content to a file
file_put_contents(__DIR__ . "/data.xml",$data);

Leave a Reply

Your email address will not be published.