I am trying to upload a file from my webserver to a remote server via a POST form. The problem is that the postData appears to get dropped by libCurl. It is sending headers with a content length of 0. I have tried using a string instead of an array, but the file is not passed just the path to it.
PHP Code:
$postData = array();
//simulates <input type="file" name="file_name">
$postData[ 'submit' ] = "Upload";
$postData[ 'var1' ] = "1048576";
$postData['var2'] = $var2;
$postData['var3'] = $var3;
$postData['var4'] = $var4;
$postData[ 'file' ] = "@$file";
$url = "path.to/upload.form";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url );
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POST, 1 );
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
curl_setopt($ch, CURLOPT_VERBOSE, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
//curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.5) Gecko/20041214 Firefox/1.0");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_COOKIE, $cookie);
curl_setopt($ch, CURLOPT_REFERER, "path.to/upload.form");
$rtnValue = curl_exec($ch);
curl_close($ch);