Re: curl extension downloads 1 byte only from zip files
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.php archive

Re: curl extension downloads 1 byte only from zip files

From: benji <benpjohnson@gmail.com>
Date: Wed Jul 13 2005 - 02:05:30 CEST

Thanks for the feedback it has helped my understanding of the problem.

Here is a cut down version of the code I am using. Sorry about omitting
the url I don't think the company would be impressed if I posted it in
a public forum.

I have also posted the responce headers below. I think that the
Content-Disposition: attachment; part is the key. I am guessing that
curl is downloading the result of the url (nothing) rather than the
file the headers are pointing to unfortunality I still cant seem to
find any relevent information that explains how curl handles this
situation.

-Ben

$ch = curl_init('url');

$fp = fopen("downloaded.zip", "w");

curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
curl_setopt($ch, CURLOPT_FILE, $fp);

$downloaded = curl_exec($ch);

curl_close($ch);

fclose($fp);

HTTP/1.1 200 OK
Date: Tue, 12 Jul 2005 23:42:34 GMT
Server: Apache/2.0.46 (Red Hat)
Accept-Ranges: bytes
X-Powered-By: PHP/4.3.2
Set-Cookie: PHPSESSID=ddb9c654715d488d3f6036127b1d624d; path=/
Cache-Control: must-revalidate
Content-Length:
Content-Disposition: attachment; filename=awcsv.zip
Connection: close
Content-Type: application/zip

[plaintext awcsv.zip]
Received on Mon Oct 17 21:06:08 2005