I’m working on a small script that will use the post method to send a file and a couple other parameters to an external form. In order to post the form I’m using curl. I’ve succeed in sending a post command when using a static file. Now however, I need to figure out how to integrate it using a dyanmically cretaed file at a specified url.
This is what I have, however I don’t think the file is being handled correctly. I’m not sure exactly how to handle it because it is not a physical file so much as a script location which generates a file.
$fileurl = "http://www.ascriptonmywebsite";
$file = file($fileurl);
$url = 'http://www.myotherwebsite.com';
$area = "test";
$params = array(
'area'=>$area,
'fname' => "@$file"
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
curl_exec($ch);
curl_close($ch);