php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41610 Using curl upload *.mid - MIME type is wrong.
Submitted: 2007-06-06 10:26 UTC Modified: 2007-06-06 10:46 UTC
From: jiawan1234 at yahoo dot com Assigned:
Status: Not a bug Package: cURL related
PHP Version: 4.4.7 OS: All
Private report: No CVE-ID: None
 [2007-06-06 10:26 UTC] jiawan1234 at yahoo dot com
Description:
------------
When using curl upload file, mine type.

eg: .mid .mid 

.mid or .midi should be "audio/midi" not "application/octet-stream"

please check below...

Reproduce code:
---------------
function my_curl($url, $dataflds)
{
 $ch = curl_init();
 curl_setopt ($ch, CURLOPT_URL, $url);
 curl_setopt ($ch, CURLOPT_HEADER, true);
 curl_setopt ($ch, CURLOPT_POST, true);
 curl_setopt ($ch, CURLOPT_POSTFIELDS, $dataflds);
 $result = curl_exec($ch);
 curl_close($ch);
 return $result;
}

$postdata['image_file'] = "@whiteflower.jpg";
$postdata['sound_file'] = "@MusicBox.mid";

echo my_curl("http://abc.com/info.php", $postdata);

exit;

Expected result:
----------------
_FILES["image_file"]	

Array
(
    [name] => whiteflower.jpg
    [type] => image/jpeg
    [tmp_name] => /var/tmp/phpwxA1au
    [error] => 0
    [size] => 14546
)

_FILES["sound_file"]	

Array
(
    [name] => MusicBox.mid
    [type] => application/octet-stream
    [tmp_name] => /var/tmp/phpp2qVwa
    [error] => 0
    [size] => 6569
)

Actual result:
--------------
_FILES["image_file"]	

Array
(
    [name] => whiteflower.jpg
    [type] => image/jpeg
    [tmp_name] => /var/tmp/phpwxA1au
    [error] => 0
    [size] => 14546
)

_FILES["sound_file"]	

Array
(
    [name] => MusicBox.mid
    [type] => audio/midi
    [tmp_name] => /var/tmp/phpp2qVwa
    [error] => 0
    [size] => 6569
)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-06-06 10:46 UTC] scottmac@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

cURL has limited mechanisms for detecting the mime type, it is based on file extension.

From the cURL manual at http://curl.haxx.se/docs/manual.html you can specify the mime type by adding type after the name, in your case you would use "@MusicBox.mid;type=audio/midi"


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 11:01:30 2024 UTC