2016-08-15 85 views
-3
<?php 

// ftp URL to file 
$url = 'sftp site'; 

// init curl session with FTP address 
$ch = curl_init($url); 

// specify a callback function for reading data 
curl_setopt($ch, CURLOPT_READFUNCTION, 'readCallback'); 
curl_setopt($ch, CURLOPT_PROTOCOLS, CURLPROTO_SFTP); 

// send download headers for client 
header('Content-type: application/octet-stream'); 
header('Content-Disposition: attachment; filename="backup.tar.bz2"'); 

// execute request, our read callback will be called when data is available 
curl_exec($ch); 


// read callback function, takes 3 params, the curl handle, the stream to read from and the maximum number of bytes to read  
function readCallback($curl, $stream, $maxRead) 
{ 
// read the data from the ftp stream 
$read = fgets($stream, $maxRead); 

// echo the contents just read to the client which contributes to their total download 
echo $read; 

// return the read data so the function continues to operate 
return $read; 
} 

當我剛剛安裝PHP捲曲,的libcurl和捲曲,該腳本返回和空白文件 但是,當我安裝有蔭回購一切需要什麼PHP擴展才能運行這個PHP腳本?

yum install php-* 

一切正常

+1

閱讀錯誤日誌。 –

+0

順便說一句,你在這裏沒有迴應什麼,你期望什麼? –

+0

@mulder沒有錯誤日誌 –

回答

0

PHP由於使用捲曲功能而引起的捲曲延伸。

+0

當我剛剛安裝php-curl,libcurl和curl時,腳本返回一個空白文件 –

相關問題