php - curl halts script execution -
My script uses curls to upload images to the site. I loop through a folder and upload every image there but after uploading 3-4, curl_exec will fail, prevent everything from uploading and uploading other images. $ Sign_id, "albumID" = & gt; $ alb_id, "$ sign_id" = " "Filename" = & gt; zerofill ($ n, 3). ".jpg", "data" => base64_encode ($ data), "bytecount" = & gt; strlen ($ data), "MD5Sum" = & Gt; $ data_md5); $ Ch = curl_init (); Curl_setopt ($ ch, CURLOPT_POST, true); Curl_setopt ($ CH, CURLOPT_RETURNTRANSFER, true); Curl_setopt ($ CH, CURLOPT_SSL_VERIFYHOST, 0); Curl_setopt ($ CH, CURLOPT_SSL_VERIFYPEER, 0); Curl_setopt ($ CH, CURLOPT_POSTFIELDS, $ upload_array); Curl_setopt ($ c, CURLOPT_URL, "https://upload.smugmug.com/services/api/rest/1.2.2/"); $ Upload_result = Curl_xac ($ CH); // fails here curl_ close ($ ch);
Updated: So I added logging to my script. When this fails, the logging stops FILIT ($ FH, "start curl \ n");
FILIT ($ FH, "start curl \ n"); $ Upload_result = Curl_xac ($ CH); FILIT ($ FH, "curl executed \ n"); FILIT ($ FH, "curl info:" .print_art (curl_getinfo ($ ch, true)). "\ N"); Fillit ($ FH, "XML Dump: $ Upload_racelet \ n"); FILIT ($ FH, "curl error:" .curl_error ($ ch). "\ N");
I also
curl_setopt ($ ch, CURLOPT_CONNECTTIMEOUT, 60 * 60);
Make sure the problem is ... what happens in the response when it fails it happens ? What are the system and Apache logs?
Now if I were you I do not use the loop in I \ "cURL_init () and curl_close ()
. Instead of the init and loop before the loop I will use the curl_set_opt
to set the URL and different parameters within Loop EtySEF and just call curl_exec ()
. It can handle any of these types of systems or more than some things if you want to use multiple connections. You can use curl_multi
or you can write some management functions / classes to manage multiple handles.
Comments
Post a Comment