2
    $fp = 'test.png';
    $server_file = "dir/testing.png";

    //-- Connection Settings
    $ftp_server = 'ftp.net';; // Address of FTP server.
    $ftp_user_name ='user'; // Username
    $ftp_user_pass = 'password'; // Password

    // set up basic connection
    $conn_id = ftp_connect($ftp_server,21);

    // login with username and password
   $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);       
   $mode = ftp_pasv($conn_id, TRUE);

   $download=ftp_get($conn_id, $fp, $server_file, FTP_BINARY);
    // try to download $server_file and save to $local_file
    if ( $download) {
        echo "Successfully $fp\n";

    } else {
        echo "There was a problem\n";
    }

    ftp_close($conn_id);

当我运行它时,它说它成功,但不会写入或下载文件。如果我echo file_get_contents($fp);那么它将显示解构为文本的图像 [在 Web 浏览器中]

需要下载图片和视频...

4

1 回答 1

1

尝试添加

header('Content-Type: image/png');
于 2014-09-07T21:01:22.763 回答