2016-08-15 215 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时,脚本返回一个空白文件 –

相关问题