How do I Upload XML file using cUrl?

From: Date: Fri, 12 Jun 2009 13:06:49 +0000
Subject: How do I Upload XML file using cUrl?
Groups: php.general 
Request: Send a blank email to php-general+get-293972@lists.php.net to get a copy of this message
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] sleepwalker@rahulsjohari.com [Web] http://www.rahulsjohari.com

« previous php.general (#293972) next »