cURL / Mailing Lists / curl-users / Single Mail

curl-users

PHP libCurl for http multipart-form upload

From: ed <ed_at_livingtoday.tv>
Date: Tue, 09 Dec 2003 16:24:56 -0500

Help!!! curl newbie in deep!!!

I am trying to emulate a http multipart form upload using libcurl in PHP.

Systems Parameters:
OS - Windows XP
Apache_2.0.47
PHP 4.3.0 dev
libcurl/7.10.5 OpenSSL/0.9.7b zlib/1.1.4

Code Sample:
$url = "http://design/uyoffice/test/testrcv.php";
$logo.gif = "logo.gif";
$sendvars['fname'] = "John";
$sendvars['lname'] = "Smith";
$sendvars['upfile'] = "@$logo";
$enc=array();
foreach($sendvars as $key=>$value)
$enc[]=urlencode($key)."=".urlencode($value);
$ch=curl_init($url);
curl_setopt($ch,CURLOPT_HEADER,0);
curl_setopt($ch,CURLOPT_VERBOSE,0);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_POST,1);
curl_setopt($ch,CURLOPT_POSTFIELDS,implode("&",$enc));
$result = curl_exec($ch);
curl_close($ch);

Transfer results:
Variables "fname" and "lname" contain appropriate content,
but instead of a file transfer, I get "@logo.gif" in variable 'logo.gif'.

The transfer behaves as a form method get, not post.

Can anyone tell me what I am doing wrong?

Ed Neilson
ed_at_epsit.net

-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills. Sign up for IBM's
Free Linux Tutorials. Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
Received on 2003-12-09