#27023 [Asn]: CURL: CURLOPT_POSTFIELDS does not parse content types for files

From: Date: Mon, 26 Jan 2004 00:02:14 +0000
Subject: #27023 [Asn]: CURL: CURLOPT_POSTFIELDS does not parse content types for files
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-53876@lists.php.net to get a copy of this message
ID: 27023 Updated by: sniper@php.net -Summary: CURLOPT_POSTFIELDS does not parse content types for files Reported By: brianl at stcu dot org Status: Assigned -Bug Type: cURL related +Bug Type: Feature/Change Request Operating System: * -PHP Version: 4CVS, 5CVS(?) +PHP Version: 4CVS, 5CVS Assigned To: sniper New Comment: This is not bug but feature request. Passing just "@/path/to/file.ext" works fine. The content-type is detected by curl (if it can). Reclassified. Previous Comments: ------------------------------------------------------------------------ [2004-01-25 00:46:23] sniper@php.net There's something fishy going on when using an array for POSTFIELDS. I'm looking into this now. ------------------------------------------------------------------------ [2004-01-23 13:26:19] brianl at stcu dot org Description: ------------ From the cURL manual: If you want the contents to be read from a file, use <@filename> as contents. When specifying a file, you can also specify the file content type by appending ';type=<mime type>' to the file name. However, specifing MIME types is not currently supported within PHP. Reproduce code: --------------- $ch= curl_init('http://www.example.com/fupl.php'); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); curl_setopt($ch,CURLOPT_POSTFIELDS, array('field1'=>'1','field2'=>'2','file'=>'@filepath.ext;type=application/xml')); $result= curl_exec($ch); curl_close($ch); Expected result: ---------------- The file should be uploaded with a Content-Type: application/xml header. Actual result: -------------- The entire call fails. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=27023&edit=1

« previous php.bugs (#53876) next »