[PHP] How do I Upload XML file using cUrl?

[email protected] ("Rahul S. Johari")
Newsgroups php.general
Message-ID <[email protected]>
Ave,

I have a client who used Lead360.Com to manage their Leads. We have a  
Leads Management application in place that creates an XML file of the  
lead which give the client manually to download.

What are client is requesting is to POST the XML File directly to  
their Leads360.Com account. We have a POST Url from Leads360 where we  
can send the lead, but I'm not sure what kind of a cUrl script I need  
to use to POST an XML file. I've handled POST Data before using cUrl  
but I haven't written a cUrl script that uploads a file to a URL.

 From what I have gathered so far ... this is what I have ...

[CODE]

$filename = "file.xml";
$handle = fopen($filename, "r");
$XPost = fread($handle, filesize($filename));
fclose($handle);

$url = "https://secure.leads360.com/Import.aspx";
$ch = curl_init(); // initialize curl handle

curl_setopt($ch, CURLOPT_VERBOSE, 1); // set url to post to
curl_setopt($ch, CURLOPT_URL, $url); // set url to post to
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // return into a variable
curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml"));
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 40); // times out after 4s
curl_setopt($ch, CURLOPT_POSTFIELDS, $XPost); // add POST fields
curl_setopt($ch, CURLOPT_POST, 1);

$result = curl_exec($ch); // run the whole process

[END CODE]

Am I on the right track here or am I missing something?

Thanks Guys!

---
Rahul Sitaram Johari
Founder, Internet Architects Group, Inc.

[Email]	[email protected]
[Web]	http://www.rahulsjohari.com
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.