PHP使用curl post将文件从服务器上传到另一台服务器

I need some help please.

I have a php script which generates a xml file and then i need to submit this to another server using POST. The XML file is ok as i can manually upload it using curl from the command line.

my code is:

$file = 'temp.xml';
file_put_contents($file, $output);
$post = array('extra_info' => '123456','file_contents'=>'@'.$file);
$url = "<URL>";
$chlead = curl_init();
curl_setopt($chlead, CURLOPT_USERPWD, "<USER>:<PASSWORD>");
curl_setopt($chlead, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($chlead, CURLOPT_URL, $url);
curl_setopt($chlead, CURLOPT_VERBOSE, 1);
curl_setopt($chlead, CURLOPT_POST,1);
curl_setopt($chlead, CURLOPT_POSTFIELDS, $post);
curl_setopt($chlead, CURLOPT_RETURNTRANSFER, false);
$response = curl_exec($chlead);

I can manually upload the file to the server which handles is correctly by:

curl -v -k -u <USER>:<PASSWORD> -X POST --upload-file temp.xml <URL>

What am i missing? I am using PHP 5.2.17. Also if there is a way of doing this without writing the xml file to disk that would be good to know.

Thanks

check the target and the file url path is correct or use the absolute path