Posting with PHP and Curl, deep array

Nllxnixv

New Member
I'm trying to post via curl, I've been using the same code over and over again with no problem but now I need to be able to use an array for posts (i'm not sure if there's a proper term for that?).I should clarify that it's specifically a file i'm trying to post, but I can't get it working with a string either so I don't think it's too do with that.This is absouletly fine:$uploadData = http://stackoverflow.com/questions/3622448/array();$uploadData['uploads'] = "@".$file;$uploadData['iagree'] = 'on';This doesn't appear to work:$uploadData = http://stackoverflow.com/questions/3622448/array();$uploadData['uploads'][0] = "@".$file;$uploadData['iagree'] = 'on';In the second example i'm trying to replicate an input with the attribute name="uploads[]"Obviously i'm trying to curl an external site, but if I experiment curling a page on my own server so that I can see what's being sent, I can see that the uploads array is being converted to a string:print_r($_POST);print_r($_FILES);returns:Array( [uploads] => Array [iagree] => on)Array()This is my full Curl: $uploadData = http://stackoverflow.com/questions/3622448/array(); $uploadData['uploads'][] = "@".$file; $uploadData['iagree'] = 'on'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $theLink); curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file); curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $uploadData); $upload_response = curl_exec($ch); curl_close($ch);I've tried to give as much information as possible, but if i've missed something feel free to ask and i'll provide more.Other than that, does anyone have any suggestions or solutions?
 
Back
Top