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

curl-and-php

similar question - posting a file with curl

From: Adam Schwartz <get_adam_at_yahoo.com>
Date: Sat, 22 Jun 2002 10:28:50 -0700 (PDT)

OK I'll try to make this a simple question. I have
been working on it for several days and need help!

I am using php and curl.

Basically I want to retrieve and image and some text
from an HTML form (i think I am doing this part
correctly already) and then post it to another php
program from within mine. I am able to do this
perfectly without the image, adding the image
complicates everything.

Here is my curl code:

$ch = curl_init("");

curl_setopt($ch, CURLOPT_URL,$URLtoPost);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $myData);

curl_exec ($ch);
curl_close ($ch);

Now when $myData is a string that contains all the
fields (except for the image) everything works.

So I though I could turn the image into a string and
put that string into the string of fields that was
already working:

$myImgData=urlencode(fread(fopen($image,"r"),filesize($image)));

$myData .= "image=".$myImgData;

I'm not sure what happens here, but the recieving
program seems to just ignore the image part...
everything else still works.

Next I thought I could make an associative array
instead of a string to send to curlopt_postfields. I
get the following error message from the program I
post to:

Warning: Supplied argument is not a valid MySQL result
resource in /home/sites/site53/web/shop/global.php on
line 697

This seems to be an internal issue to the global.php
program which I won't bother you with unless it is
requested.

Finally, I have a theory that I could use curlopt_file
in conjuction with curlopt_postfields. But I'm not
sure how this works.

I'm a little flustered here and could use a specific
example of some program that does this or an
explanation of how it can be achieved. Thanks,

adam

__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com

-------------------------------------------------------
Sponsored by:
ThinkGeek at http://www.ThinkGeek.com/
Received on 2002-06-22