Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • CURL: How to download file from ftp using curl?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 1.8k
    Comment on it

    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)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: