PHP Curl download PDF files
<p>What is the proper way to download like 50+ PDF files using PHP curl?</p>

<p>Below is the code I am using:</p>

<pre><code>$fp = fopen("test.pdf", 'w');        
$ch = curl_init();

curl_setopt($ch,CURLOPT_PROXY,"http://test:123");
curl_setopt($ch,CURLOPT_PROXYPORT,123);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 0);
curl_setopt ($ch, CURLOPT_TIMEOUT, 500);
curl_setopt($ch,CURLOPT_URL,"http://download/test.pdf");
curl_setopt($ch, CURLOPT_FILE, $fp);

curl_exec($ch);
curl_close($ch);
fclose($fp);
</code></pre>

<p>The problem is sometimes, 2-3 PDF files are not properly downloaded (0-1 bytes in size). Any idea why it is unstable? Must I include anything else in the code above?</p>

<p>Thanks In Advance</p>
