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

curl-and-php

RE: multipart form

From: Matt Parkins \(home\) <matt_at_the-parkins.co.uk>
Date: Tue, 1 Feb 2005 11:37:27 -0000

 
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello,

I'm using CURL in PHP and this works fine for me - I had trouble
until I removed the other curl_setops that conflicted with
CURLOPT_POSTFIELDS - the problem was that I didn't really know which
ones confliced! This is what I do:

$postdata = array;
$postdata['myfile'] = "@myfile.ext";

//-[snip]- (add any other data you want to send with the file in
that array)

$curl =
curl_init(_MY_SERVER_ADDRESS."functions/processreturndata.php");

curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata);
curl_exec($curl);

$succeeded = (curl_errno($curl) == 0);

if (!$succeeded)
{
        $str = "failed to return data to processreturndata.php because:
".curl_error($curl);
        echo "$str\n";
        $log->write($str);

        //do something with fail I guess!
}

curl_close($curl);

I hope this helps :@)

Matt

- -----Original Message-----
From: curl-and-php-bounces_at_cool.haxx.se
[mailto:curl-and-php-bounces_at_cool.haxx.se] On Behalf Of Mikolaj Jan
Podlaszewski
Sent: 01 February 2005 10:45
To: curl-and-php_at_cool.haxx.se
Subject: multipart form

Is it possible to mimic multipart form with file field with PHP/CURL?
If so what is the proper way?

The problem seems to be simple but the more I read the more mess
comes to my head. I saw some examples giving '@filename' as POST
variable value but they results in "failed creating formpost data"
error.

Man pages says to use CURLOPT_HTTPPOST for file upload. Unfortunately
earlier post from that list
(http://curl.haxx.se/mail/curlphp-2001-10/0002.html) says it is
unsupported in PHP yet. Have things changed till year 2001?

Could you please describe what is the current state of the problem?

Thanks
M.

Using PHP 4.3.10 with libcurl/7.12.3 OpenSSL/0.9.7e zlib/1.1.4

-----BEGIN PGP SIGNATURE-----
Version: PGP 8.1

iQA/AwUBQf9p9ytTzPm4J+DXEQKDhgCgxD8iPJxfP5TXOw2VOyZXfH0iLXsAoP4u
MrzOdJgHB8YzA4zefkI5webc
=0iXI
-----END PGP SIGNATURE-----
Received on 2005-02-01