cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: PHP curLib

From: <swdlst_at_indoorstorm.com>
Date: Wed, 10 Dec 2003 15:53:04 -0500

<?php
//$url = "http://design/uyoffice/test/testrcv.php";

//This means $logo=''
//$logo.gif = "logo.gif";
$logo = "logo.gif";
$sendvars['fname'] = "John";
$sendvars['lname'] = "Smith";

//PHP will ignore the @
//$sendvars['upfile'] = @$logo;
$sendvars['upfile'] = "@$logo";

//Multi-part form data should not be NOT be urlencoded
//$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));
curl_setopt($ch,CURLOPT_POSTFIELDS,$sendvars);
$result = curl_exec($ch);
curl_close($ch);
?>

Dave...
----- Original Message -----
From: "ed" <ed_at_livingtoday.tv>
To: <curl-library_at_lists.sourceforge.net>
Sent: Tuesday, December 09, 2003 5:02 PM
Subject: PHP curLib

> 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
>

-------------------------------------------------------
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-10