Announcement

#1 2015-05-19 18:56:22

peep
Member
2015-05-19
2

Error on uploading image through api (forbidden file type)

Hi,

I tried to build a small tool to handle the images for our NGO.
I wrote it in vb.net.

The login works, I can get the categories, but if I try to upload an image I get the error "Forbidden file type".
I used an other php script where I just output the content of the $_POST and $_FILES, there I get this response:

$_POST:
array(2) {
  ["method"]=>
  string(20) "pwg.images.addSimple"
  ["category"]=>
  string(2) "94"
}

$_FILES:
array(1) {
  ["image"]=>
  array(5) {
    ["name"]=>
    string(17) "IMGP0189 mini.jpg"
    ["type"]=>
    string(10) "image/jpeg"
    ["tmp_name"]=>
    string(25) "/mnt/shared/tmp/php8Naq.3"
    ["error"]=>
    int(0)
    ["size"]=>
    int(61455)
  }
}

I hope someone can help me with that.

Best regards
Timo

Piwigo version: 2.7.3
PHP version: 5.6.8
MySQL version: 5.5.43-log [2015-05-19 18:52:41]
Piwigo URL: http://abaana.de/fotos/

Offline

 

#2 2015-05-19 22:52:50

peep
Member
2015-05-19
2

Re: Error on uploading image through api (forbidden file type)

small update:
I got the line in the code where the problem is:
    list($width, $height, $type) = getimagesize($source_filepath);

There are no information in $width, $height and $type. If I try to set $type manually, there is no error message but the image is broken and can not be displayed.

Someone an idea what I can do now?

BR
Timo

Offline

 

#3 2015-05-19 23:13:29

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13791

Re: Error on uploading image through api (forbidden file type)

Hi peep,

There may be a problem with the file upload. Do you correctly set the "content type" to form-data in your POST request? See my example in Perl on http://piwigo.org/doc/doku.php?id=dev:w … .addsimple

Another way to upload is to use pwg.images.upload (which is not correctly documented yet, because I thought only the HTML5 admin form would use it, but the new iOS app already use it...).

You can still use the original API upload, which is N * pwg.images.addChunk + pwg.images.add, see http://piwigo.org/doc/doku.php?id=dev:w … images.add : it doesn't rely on form-data and FILES request.

Offline

 

#4 2017-05-03 10:51:06

blacktea
Member
2017-05-03
11

Re: Error on uploading image through api (forbidden file type)

I think the problem is the space in the file name

IMGP0189 mini.jpg

try with

IMGP0189_mini.jpg

Offline

 

Board footer

Powered by FluxBB

github twitter newsletter Donate Piwigo.org © 2002-2024 · Contact