卷曲下载文件

时间:2013-03-26 07:19:24

标签: curl

我有一个网址,当从浏览器运行时,它开始下载文件(ebup或pdf) 因为网址包含姓名和密码,所以我不能给我的客户端这个网址 我必须创建一个文件到我的服务器download.php,它将使用curl下载文件。

让我们说网址是www.myebookspartner.com/username/ebooks/password/1234/ebookid/12

当我尝试使用curl调用此url时,下载无法启动(如果我运行表单浏览器,则立即启动下载)

 $ch = curl_init();
 curl_setopt($ch, CURLOPT_URL,$url);

 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);        
 curl_setopt($ch, CURLOPT_HEADER, 1);
 curl_setopt($ch, CURLOPT_NOBODY, 1);               
 $server_output = curl_exec ($ch);  
 $info=curl_getinfo($ch);           
 curl_close ($ch);

curl_getinfo返回

{
  ["url"]=the url"
  ["content_type"]=>
  string(35) "application/epub+zip; charset=utf-8"
  ["http_code"]=>;
  int(200)
  ["header_size"]=>
  int(861)
  ["request_size"]=>
  int(318)
  ["filetime"]=>
  int(-1)
  ["ssl_verify_result"]=>
  int(0)
  ["redirect_count"]=>
  int(0)
  ["total_time"]=>
  float(5,622246)
  ["namelookup_time"]=>
  float(0,000764)
  ["connect_time"]=>
  float(0,056946)
  ["pretransfer_time"]=>
  float(4,8E-5)
  ["size_upload"]=>
  float(0)
  ["size_download"]=>
  float(0)
  ["speed_download"]=>
  float(0)
  ["speed_upload"]=>
  float(0)
  ["download_content_length"]=>
  float(510415)
  ["upload_content_length"]=>
  float(0)
  ["starttransfer_time"]=>
  float(5,622168)
  ["redirect_time"]=>
  float(0)
}

如何使用curl强制从我的文件下载文件

由于

0 个答案:

没有答案
相关问题