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

curl-and-php

RE: How to POST a big amount of data?

From: Fluteau Jerome ICM N PG U PLM A 2 <jerome.fluteau_at_siemens.com>
Date: Thu, 21 Nov 2002 16:53:06 +0100

I use now a different URL to access to the server and actually he has no
problem with POST. As often it was certainly
a silly problem but when I tried to do the error again in order to get what
was wrong, I didn't succeed in it!!!

Anyway here is how I made it:

First of all, the connection: I launch this code only one time until my
connection is dead:

<?php
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL,
"https://my-server.com/servlet?username=login&password=pass");
curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie.txt");//the cookie is stored by
default in Apache2 folder.
ob_start(); // prevent any output
curl_exec ($ch); // execute the curl command
ob_end_clean();
curl_close($ch);
?>

Now the cookie allows me to do whatever I want with the servlet in all my
php files. I don't really
know how the servlet knows, with this simple code, which form I want to
update but it works:

<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://my-server.com/servlet");
curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS,$post);
$result = curl_exec ($ch);
curl_close($ch);

?>

Regards,

Jerome.

-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
Received on 2002-11-21