This blog will let you download files from ftp
using curl
. Ftp url is given below. From this url we need to download this file filename.gz
ftp://ftp.example.se/filename.gz
Following is the working example:
$curl = curl_init();
$file = fopen("filename.gz", 'w');
curl_setopt($curl, CURLOPT_URL, "ftp://ftp.example.se/filename.gz"); #input
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_FILE, $file); #output
curl_setopt($curl, CURLOPT_USERPWD, "$_FTP[username]:$_FTP[password]");
curl_exec($curl);
curl_close($curl);
fclose($file);
Replace filename.gz from your filename and replace the ftp url with your ftp
Now run this example. All done now.
Thanks for reading the blog.
0 Comment(s)