php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47217 content-type is not set properly
Submitted: 2009-01-26 11:19 UTC Modified: 2009-01-26 15:20 UTC
From: gubp at pisti dot hu Assigned:
Status: Closed Package: cURL related
PHP Version: 5.2.8 OS: FreeBSD
Private report: No CVE-ID:
 [2009-01-26 11:19 UTC] gubp at pisti dot hu
Description:
------------
Using the cURL to send files with custom content-type (eg.: "@filename;type=content-type") does not work, because undesirable "type=" string is preprended to the actual content-type.

Reproduce code:
---------------
test.php:
---------

$data = array('file' => '@sheet.xls;type=application/vnd.ms-excel');

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://localhost/upload.php');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_exec($ch);

echo curl_error($ch);


upload.php:
-----------
print_r($_FILES);


Expected result:
----------------
Array
(
    [file] => Array
        (
            [name] => sheet.xls
            [type] => application/vnd.ms-excel
            [tmp_name] => /var/tmp/php21KVfg
            [error] => 0
            [size] => 1192
        )

)


Actual result:
--------------
Array
(
    [file] => Array
        (
            [name] => sheet.xls
            [type] => type=application/vnd.ms-excel
            [tmp_name] => /var/tmp/php21KVfg
            [error] => 0
            [size] => 1192
        )

)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-01-26 15:20 UTC] iliaa@php.net
This bug has been fixed in CVS.

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/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Sun Apr 20 15:01:54 2014 UTC