运行这个php脚本需要什么php扩展?

时间:2016-08-15 05:55:41

标签: php curl sftp

<?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-curl,libcurl和curl时,脚本返回并且空白文件 但是,当我安装yum repo上的所有内容时

yum install php-*

一切正常

1 个答案:

答案 0 :(得分:0)

由于使用了curl函数,PHP卷曲扩展。