Edit report at https://bugs.php.net/bug.php?id=46696&edit=1

 ID:                 46696
 Comment by:         kotlyar dot maksim at gmail dot com
 Reported by:        marceloburegio at gmail dot com
 Summary:            cURL fails in upload files with specified
                     content-type
 Status:             Closed
 Type:               Bug
 Package:            cURL related
 Operating System:   Linux and Windows
 PHP Version:        5.2.6
 Block user comment: N
 Private report:     N

 New Comment:

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)


Previous Comments:
------------------------------------------------------------------------
[2008-11-27 17:03:30] il...@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.



------------------------------------------------------------------------
[2008-11-27 13:06:40] 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



------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=46696&edit=1

Reply via email to