I consistently get the error 'failed creating formpost data' from the below code, the same thing works perfectly on my local testing server, but on my shared host it throws the error.
The sample part is just to simulate building the array with both files and non-file data. Essentially all I'm trying to do here is redirect the same http request to another server, but I'm running into so many troubles.
$count=count($_FILES['photographs']['tmp_name']);
$file_posts=array('samplesample' => 'ladeda');
for($i=0;$i<$count;$i++) {
if(!empty($_FILES['photographs']['name'][$i])) {
$fn = genRandomString();
$file_posts[$fn] = "@".$_FILES['photographs']['tmp_name'][$i];
}
}
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,"http://myurl/wp-content/plugins/autol/rec.php");
curl_setopt($ch,CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
curl_setopt($ch,CURLOPT_HEADER,TRUE);
curl_setopt($ch,CURLOPT_POST,TRUE);
curl_setopt($ch,CURLOPT_POSTFIELDS,$file_posts);
curl_exec($ch);
print curl_error($ch);
curl_close($ch);