download a file from ftp using curl and php

前端 未结 6 1638
伪装坚强ぢ
伪装坚强ぢ 2020-11-30 03:32

I\'m trying to download a file from an ftp server using curl and php but I can\'t find any documentation to help

$curl = curl_init();
curl_setopt($curl, CURL         


        
6条回答
  •  悲哀的现实
    2020-11-30 03:46

    After trying all of these answers and having none of them work, this is what I finally got to work.

    $curl = curl_init();
    $fh   = fopen("FILENAME.txt", 'w');
    curl_setopt($curl, CURLOPT_URL, "ftp://{$serverInfo['username']}:{$servererInfo['password']}@{$serverInfo['server']}/{$serverInfo['file']}");
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    $result = curl_exec($curl);
    fwrite($fh, $result);
    fclose($fh);
    curl_close($curl);
    

提交回复
热议问题