php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46696 cURL fails in upload files with specified content-type
Submitted: 2008-11-27 13:06 UTC Modified: 2008-11-27 17:03 UTC
From: marceloburegio at gmail dot com Assigned:
Status: Closed Package: cURL related
PHP Version: 5.2.6 OS: Linux and Windows
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: marceloburegio at gmail dot com
New email:
PHP Version: OS:

 

 [2008-11-27 13:06 UTC] marceloburegio at gmail dot com
Description:
------------
Using the cURL to send files with the Content-Type different of set in cURL (Eg.: "@filename;type=content-type"), PHP reads entire string after the @ and tries to find the file, that does not exists because of ";type=".

Running an I/O monitor, verified that PHP tries to find the file "filename;type=content-type" (defined after @), which in fact does not exist.

Probably the problem is in interface.c, in line 1484, where the string wasn't separated in filename and content-type.

The above procedure was followed the response of the bug reported in #41610, the manual of cURL in http://curl.haxx.se/docs/manual.html, in addition to comments of this issue in http://curl.haxx. se/mail/curlphp-2007-12/0033.html


Reproduce code:
---------------
# File 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);


# File upload.php
-------------------
print_r($_FILES);


Expected result:
----------------
# Response of test.php
------------------------
Array
(
    [file] => Array
        (
            [name] => sheet.xls
            [type] => application/vnd.ms-excel
            [tmp_name] => /tmp/php2B8.tmp
            [error] => 0
            [size] => 13824
        )
)


Actual result:
--------------
# Response of test.php
------------------------
failed creating formpost data


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-11-27 17:03 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.


 [2012-08-03 12:53 UTC] kotlyar dot maksim at gmail dot com
I succeeded to change type(content-type) but not a filename. Is it really fixed?

Ubuntu 12.04, PHP 5.4.4-1~precise+1 (cli) (built: Jun 17 2012 13:01:09)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 14:01:29 2024 UTC