cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

Re: posting files

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Wed, 30 May 2001 08:42:33 +0200 (MET DST)

On Wed, 30 May 2001, Jose Antonio Mercado wrote:

> Hi I'm traying to HTTP post files from a php script using curl functions
> but it's not working. Which curl option should I use and how should I
> write the value for that option? I'm using the fallowing code:
>
> $ch = curl_init ();
> url_setopt ($ch,CURLOPT_URL,"http://localhost/test.php");
> curl_setopt ($ch,CURLOPT_POSTFIELDS,"archivo=@/tmp/foo"); // Not sure
> about this
> $res=curl_exec ($ch);
> curl_close ($ch);
>
> The post target script is recieving data like a
> application/x-www-from-urlencoded and not the contents of the file foo.

Exactly, as you're doing a application/x-www-from-urlencoded POST, which
CURLOPT_POSTFIELDS is used for.

> M'I missing someting? is there an option for posting multipart/form-data?

Yes and yes! ;-)

I'm not really sure how you build the formdata with PHP (the C API offers the
curl_formparse() function for this), but the option is named
CURLOPT_HTTPPOST.

-- 
     Daniel Stenberg -- curl dude -- http://curl.haxx.se/
_______________________________________________
Curl-and-php mailing list
Curl-and-php_at_lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/curl-and-php
Received on 2001-05-30