Edit report at https://bugs.php.net/bug.php?id=27023&edit=1
ID: 27023 Updated by: pierr...@php.net Reported by: brianl at stcu dot org Summary: CURL: CURLOPT_POSTFIELDS does not parse content types for files -Status: Open +Status: Closed Type: Feature/Change Request Package: cURL related Operating System: * PHP Version: * -Assigned To: +Assigned To: pierrick Block user comment: N Private report: N New Comment: This bug has been fixed in SVN. Snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. For Windows: http://windows.php.net/snapshots/ Thank you for the report, and for helping us make PHP better. Feature implemented since the bug report. Previous Comments: ------------------------------------------------------------------------ [2005-02-24 03:28:26] jplock at yahoo dot com I would very much like this functionality to be implemented in PHP5 as I need it for a project I am currently developing. Thanks. ------------------------------------------------------------------------ [2004-03-07 11:54:50] brianl at stcu dot org Since curl's ability to guess the MIME type of a file by extension is extremely limited, this represents a very important enhancement for any upload where the MIME type is used. ------------------------------------------------------------------------ [2004-01-25 19:02:13] sni...@php.net 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. ------------------------------------------------------------------------ [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 https://bugs.php.net/bug.php?id=27023&edit=1