|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #27023 CURL: CURLOPT_POSTFIELDS does not parse content types for files
Submitted: 2004-01-23 13:26 UTC Modified: 2011-12-07 16:36 UTC
Avg. Score:4.6 ± 0.5
Reproduced:4 of 4 (100.0%)
Same Version:3 (75.0%)
Same OS:4 (100.0%)
From: brianl at stcu dot org Assigned: pierrick (profile)
Status: Closed Package: cURL related
PHP Version: * OS: *
Private report: No CVE-ID: None
 [2004-01-23 13:26 UTC] brianl at stcu dot org
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('');
$result= curl_exec($ch);

Expected result:
The file should be uploaded with a Content-Type: application/xml header.

Actual result:
The entire call fails.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-01-25 19:02 UTC]
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).


 [2004-03-07 11:54 UTC] 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.
 [2005-02-24 03:28 UTC] 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.
 [2010-11-19 01:15 UTC]
-Package: Feature/Change Request +Package: cURL related -PHP Version: 4CVS, 5CVS +PHP Version: *
 [2011-12-07 16:36 UTC]
-Status: Open +Status: Closed -Assigned To: +Assigned To: pierrick
 [2011-12-07 16:36 UTC]
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

 For Windows:
Thank you for the report, and for helping us make PHP better.

Feature implemented since the bug report.
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Sat Jun 25 20:05:44 2022 UTC