#49943 [Opn->Bgs]: cURL does not upload files with specified filename
| From: | jani@php.net | Date: | Wed, 21 Oct 2009 13:35:57 +0000 |
| Subject: | #49943 [Opn->Bgs]: cURL does not upload files with specified filename | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-143756@lists.php.net to get a copy of this message | ||
ID: 49943
Updated by: jani@php.net
Reported By: p dot watras at gmail dot com
-Status: Open
+Status: Bogus
Bug Type: cURL related
Operating System: FreeBSD 7.1
PHP Version: 5.2.11
New Comment:
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same.
Thank you for your interest in PHP.
See bug #49921 and search before submit next time..
Previous Comments:
------------------------------------------------------------------------
[2009-10-21 12:56:24] p dot watras at gmail dot com
Description:
------------
This bug is similar to http://bugs.php.net/bug.php?id=48962.
As alexei suggested you have to manually edit interface.c in line
1593:
and change it to:
CURLFORM_FILENAME, filename ? filename+sizeof(";filename=") - 1 :
postval
Everything works fine after this update.
Reproduce code:
---------------
# File test1.php
$data = array('file' => '@/tmp/myfile;filename=foobar');
$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 test2.php
$data = array('file' =>
'@/tmp/myfile;filename=foobar;type=application/zip');
$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:
----------------
# Result of test1.php
Array
(
[item_file] => Array
(
[name] => foobar
[type] => application/octet-stream
[tmp_name] => /var/tmp/phpCEVFto
[error] => 0
[size] => 36257
)
)
# Result of test1.php
Array
(
[item_file] => Array
(
[name] => foobar
[type] => application/zip
[tmp_name] => /var/tmp/phpCEVFto
[error] => 0
[size] => 36257
)
)
Actual result:
--------------
Upload fails. No files are uploaded.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=49943&edit=1