cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: PHP curLib

From: ed <ed_at_epsit.net>
Date: Wed, 10 Dec 2003 11:23:11 -0500

Daniel,

Thanks for the reply:
I found the "curl-and-php" mailing list this morning and have been
reviewing it. No real help yet.

I have been playing around with the code and found some resolution.
The original example snipit I tried caused an execution error.
The cause turned out to be this statement:
     $sendvars['upfile'] = "@$logo";

Removing the quotes around @$logo corrected the error.
     $sendvars['upfile'] = @$logo; <== This cleared the error

The following code now sends as multipart, but I still don't get my file
to go.

$url = "http://design/uyoffice/test/testrcv.php";
$logo = "logo.gif";

$sendvars['fname'] = "John";
$sendvars['lname'] = "Smith";
$sendvars['upfile'] = @$logo;

$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,$sendvars);
$result = curl_exec($ch);

the content type shows as:
       multipart/form-data;
boundary=----------------------------3c0b91392537
so I am now geting multipart submittal.

My handler now has the following variable results.
$fname = John
$lname = Smith
$upfile = logo.gif <= should reflect the temp
file address
$upfile_name = null <= should reflect the file name
$upfile_type = null <= should reflect the mimetype

I am still stuck with a file name coming across, not the file itself.

Ed
ed_at_epsit.net

Daniel Stenberg wrote:

>On Tue, 9 Dec 2003, ed wrote:
>
>
>
>>Help!!! curl newbie in deep!!!
>>
>>
>
>No need to cross-post. Besides, you missed the most important mailing list for
>you: curl-and-php.
>
>
>
>>$sendvars['fname'] = "John";
>>$sendvars['lname'] = "Smith";
>>$sendvars['upfile'] = "@$logo";
>>$enc=array();
>>foreach($sendvars as $key=>$value)
>>$enc[]=urlencode($key)."=".urlencode($value);
>>curl_setopt($ch,CURLOPT_POSTFIELDS,implode("&",$enc));
>>
>>
>
>This looks very odd. Is this really the documented way to do multipart
>formposts using the PHP/CURL interface?
>
>
>

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