php - Using cURL in a loop -


i'm writing script in unspecified number of files need uploaded via curl requests remote api. however, script hangs , times out. strangely enough, requests successful (the files uploaded), script unable continue. here's loop:

foreach ($paths $path) {   $ch = curl_init($path);   curl_setopt($ch, curlopt_httpheader, array('x-auth-token: '.$token, 'content-length: '.filesize($path));   curl_setopt($ch, curlopt_put, true);   curl_setopt($ch, curlopt_infile, fopen($path, 'r'));   curl_setopt($ch, curlopt_infilesize, filesize($path));   echo curl_exec($ch); } 

i believe has loop. i've tried adding curl_close within loop, doesn't solve problem. ideas?

put timeout in curl

foreach ($paths $path) {   $ch = curl_init($path);   curl_setopt($ch, curlopt_httpheader, array('x-auth-token: '.$token, 'content-length: '.filesize($path));   curl_setopt($ch, curlopt_put, true);   curl_setopt($ch, curlopt_infile, fopen($path, 'r'));   curl_setopt($ch, curlopt_infilesize, filesize($path));   curl_setopt($ch, curlopt_connecttimeout ,0);    curl_setopt($ch, curlopt_timeout, 400); //timeout in seconds   echo curl_exec($ch); } 

Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -