I'm writing a script in which an unspecified number of files need to be uploaded via cURL requests to a remote API. However, this script hangs and eventually times out. Strangely enough, all the requests are successful (the files are successfully uploaded), but the script is unable to continue. Here's the loop:
foreach ($paths as $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 this has something to do with the loop. I've tried adding curl_close within the loop, but it doesn't solve the problem. Any ideas?
all the requests are successfulandbut the script is unable to continuetogether is likely impossible (The only chance would be that the scripts encounters a problem after successful upload of the last image)