codeminders / imageshackapi

Automatically exported from code.google.com/p/imageshackapi
0 stars 0 forks source link

Problem uploading PNG and BMP via api #6

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
hi i am using the imageshack api (xml) and i get an error when i try to
upload png and bmp files

the error i get it:
wrong file type :application/octet-stream

i dont know why cause gif and jpeg are ok..

i am using it in PHP via cURL

$data['key'] = API_KEY;
    $data['public'] = "yes";
    $data['xml'] = "yes";
    $data['fileupload'] = '@'.$dest; 

    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, 'http://www.imageshack.us/upload_api.php');
    curl_setopt($curl, CURLOPT_POST, true);
    curl_setopt($curl, CURLOPT_HEADER, false);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_TIMEOUT, 600);
    /*curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);*/
    curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
    $result = curl_exec($curl);
    curl_close($curl);

Original issue reported on code.google.com by goleech...@gmail.com on 30 Sep 2009 at 3:46

GoogleCodeExporter commented 9 years ago
unfortunately, PHP/CURL does not allow to set a content type for uploaded file 
(the 
trick that possible in command line CURL: 
fileupload=@filename.png;type=image/png)

I suggest you to use PHP library from this project instead of CURL, it allows 
to set 
content type during the upload.

Original comment by lyolik1...@gmail.com on 6 Oct 2009 at 9:00

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
ImageShack.us used to guess which file type is uploaded.
Now it's unable to detect .png and .bmp
Here's what's returned when uploading a .png file

 Wrong file type detected for file guybrush-mi1-01.png:application/octet-stream

Original comment by simpletw...@gmail.com on 10 May 2010 at 9:33