2015-11-18 44 views
0

使用Phalcon Incubator library's HTTP client您可以发出Web请求。 我想从另一台服务器下载一个zip文件到我的Phalcon项目中的特定文件夹。Phalcon使用孵化器HTTP客户端将zip文件保存到服务器

这是我到目前为止有:

$provider = Request::getProvider(); 
$provider->header->set('Accept', 'application/zip'); 
$provider->get('https://phs.googlecode.com/files/Download%20File%20Test.zip'); 

我怎么这个压缩保存到特定位置的请求之后?

回答

2

尝试:

$provider = Request::getProvider(); 
$provider->header->set('Accept', 'application/zip'); 
$response = $provider->get('https://phs.googlecode.com/files/Download%20File%20Test.zip'); 

file_put_contents('/path/to/file.zip', $response->body); 
+0

哪里'/'开始?您的Phalcon项目的根源? –

+0

['file_put_contents'](http://php.net/file_put_contents)需要文件的完整路径(如fopen),因此它从服务器的根目录开始。 – drew010

相关问题