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

curl-and-php

Send POST vars and file via PHP and libcurl

From: <domeng_at_stii.dost.gov.ph>
Date: Fri, 21 May 2004 05:04:58 +0800 (PHT)

Greetings!

Im trying to send POST vars and file using libcurl and PHP. My send script
goes like this:

SendUpdate.php
---------------------------------------------------------------
$encrypted_file = 'somefile.asc';
//snippet from a class
$postfields = array(
         "update_id" => $this->update_id,
         "update_type_id" => $this->update_type_id,
         "update_session_id" => $this->update_session_id,
         "project_code" => $this->project_code,
         "agency_code" => $this->agency_code,
         "comments" => $this->comments,
         "data" => $this->data,
         "file" => "@$encrypted_file"
//

// Begin Transferring
$ch = curl_init(); // initialize curl handle
curl_setopt($ch, CURLOPT_URL,$central_url); // set url to post to
if($proxy)
{
   curl_setopt($ch, CURLOPT_PROXY, $proxy); //proxy
}
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirects
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable
curl_setopt($ch, CURLOPT_TIMEOUT, 3); // times out after 4s
curl_setopt($ch, CURLOPT_POST, 1); // set POST method
curl_setopt($ch, CURLOPT_POSTFIELDS, "$postfields"); // add POST fields
// execute curl command
$result = curl_exec($ch); // run the whole process

--------------------End SendUpdate.php----------------------------

But when I try to receive it, with a very simple script
--------------------TestReceive.php----------------------
<?php
//echo $_POST;
echo $_POST['update_id'];
?>
------------------------------------------------------------
This displays nothing. How can i extract the 'regular' POST var and the
file. Im using PHP Version 4.3.3 and libcurl/7.10.7 OpenSSL/0.9.7b
zlib/1.1.4.

Thanks
Received on 2004-05-20