cURL / Mailing Lists / curl-and-php / Single Mail


Setting the Content-type on an uploaded in CURL + PHP

From: Bensan Benny <>
Date: Fri, 31 Aug 2007 09:05:33 -0400

This was a question that was asked several times but I have yet to find
the answer. I am using libcurl along with PHP to upload two files along
with various other data. Here's my code:

$postData['userInfo'] = "@file2.xml";

$postData['sid'] = $xml->sid;

$postData['version'] = '2.0';

$postData['docData'] = "@file1.html";

$postData['sigMap'] = 'notused';

$postData['docId'] = 17;

$postData['submit'] = 'save';


$url = "";

curl_setopt($ch, CURLOPT_URL, $url);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($ch, CURLOPT_POST, 1);

curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);

$response = curl_exec($ch);




    print curl_error($ch);



When the two files are uploaded file2.xml has a type of
'application/octet-stream'. I would like that file to have a content
type of 'text/xml'. I know that there is a way to change the
content-type of an uploaded file in native cURL so I would imagine there

is a way to do this in PHP's libcurl as well. How do we do this?

Bensan G. Benny
Software Developer
VR Software
phone: (321)219-0204
The information in this e-mail and any attached files is CONFIDENTIAL and may be legally privileged or prohibited from disclosure and unauthorized use. The views of the author may not necessarily reflect those of the Company. This communication is intended solely for the addressee, or the employee or agent responsible for delivering such materials to the addressee. If you have received this message in error please return it to the sender then delete the email and destroy any copies of it. If you are not the intended recipient, any form of reproduction, dissemination, copying, disclosure, modification, distribution and/or publication or any action taken or omitted to be taken in reliance upon this message or its attachments is prohibited and may be unlawful.
At present the integrity of e-mail across the Internet cannot be guaranteed and messages sent via this medium are potentially at risk. All liability is excluded to the extent permitted by law for any claims arising as a result of the use of this medium to transmit information by or to VillaDirect Management LLC.

Received on 2007-08-31