#46696 [Opn->Csd]: cURL fails in upload files with specified content-type
| From: | iliaa@php.net | Date: | Thu, 27 Nov 2008 17:03:30 +0000 |
| Subject: | #46696 [Opn->Csd]: cURL fails in upload files with specified content-type | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-131418@lists.php.net to get a copy of this message | ||
ID: 46696
Updated by: iliaa@php.net
Reported By: marceloburegio at gmail dot com
-Status: Open
+Status: Closed
Bug Type: cURL related
Operating System: Linux and Windows
PHP Version: 5.2.6
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[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 http://bugs.php.net/?id=46696&edit=1