cURL fails in upload files with specified content-type
| 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 | ||
[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 commits
[2008-11-27 17:03 UTC] iliaa@php.net
[2012-08-03 12:53 UTC] kotlyar dot maksim at gmail dot com