|  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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: marceloburegio at gmail dot com
New email:
PHP Version: OS:


 [2008-11-27 13:06 UTC] marceloburegio at gmail dot com
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, 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/');

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://localhost/upload.php');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

echo curl_error($ch);

# File upload.php

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

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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2008-11-27 17:03 UTC]
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
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-2022 The PHP Group
All rights reserved.
Last updated: Mon Aug 08 03:05:46 2022 UTC