I'm transferring files from an existing http request using cURL like so...
$postargs = array(
'nonfilefield' =>'nonfilevalue',
'fileentry' => '@'.$_FILES['thefile']['tmp_name'][0]
);
$ch = curl_init('http://localhost/curl/rec.php');
curl_setopt($ch,CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch,CURLOPT_POST,TRUE);
curl_setopt($ch,CURLOPT_POSTFIELDS,$postargs);
curl_exec($ch);
curl_close($ch);
The only way I can get this to work is using the tmp_name, without this it won't send. However, I then lose the name value for when I want to name the file later.
Is there some way to do this preserving the $_FILES array as it normally would be without curl? I'm also using an array of file fields in my script, so at the moment I have to convert my multidimensional array into a single dimension for this to work