cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Porblem with posting file on Windows (libcurl+php)

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Tue, 8 May 2012 16:49:03 +0200 (CEST)

On Tue, 8 May 2012, Роман Ковальский wrote:

> and then i try to do this at php + libcurl
>
> $postdata = array(
> "image[0]" => "@z:/home/localhost/www/b-s/include/ajax/title.jpg;type=image/jpeg;filename=title.jpg",
> "image[0]" => "file"
> );

This would've been better suited for the curl-and-php mailing list as that API
is not something libcurl provides but instead it is PHP/CURL specific.

I have pointed out the stupidity with that API several times and your problem
here is a perfect example why it is a bad design...

> but in protocol i see only one  name="image[0]", which was the first ...
>
> Any idea on what I might be doing wrong? Any help would be very much
> appreciated!

That's a hash array. You can only store one key with the same name, so you
each field has to use its own unique name. Unfortunately you can't emulate
that formpost using that PHP/CURL API.

> with curl all work ok:
> -F "image[0]=@title.jpg;type=image/jpeg;filename=title.jpg"
> -F "image[0]=file"

Yes, because curl (and libcurl) recognizes that you can send many parts using
the same name...

-- 
  / daniel.haxx.se

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2012-05-08