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

curl-and-php

RE: Uploading a file through curl + php

From: Matt Parkins <matt_at_parkins.uk.net>
Date: Mon, 20 Dec 2004 10:14:04 -0000

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

>> I want to use Curl to upload a file to a location on another
>> machine.

>Upload how?

Which ever way will work! I'm not too fussy! :@) The upload is a
HTTP one.

>> curl_setopt($curl, CURLOPT_POSTFIELDS, substr($str, 0, -1));
>This makes a POST.

I've tried removing this field and it doesn't seem to make a
difference - the remote HTTP URL is successfully called, but there's
nothing in the $_FILES variable..:

                $curl =
curl_init(_BACKOFFICE_ADDRESS."functions/processreturndata.php");
            $postdata['return_filesize'] = $return_filesize;
            $postdata['return_debug'] = $return_debug;
            $postdata['return_status'] = $return_status;

            $file = fopen($return_filename, "r");

            curl_setopt($curl, CURLOPT_TIMEOUT, 60);
            curl_setopt($curl, CURLOPT_VERBOSE, 1);

            //POST DOES NOT WORK WITH AN ATTEMP TO UPLOAD BELOW
            curl_setopt($curl, CURLOPT_PUT, 1);
            curl_setopt($curl, CURLOPT_INFILE, $file);
            curl_setopt($curl, CURLOPT_INFILESIZE, $return_filesize);

            curl_exec($curl);

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

- -- Matt

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

iQA/AwUBQcal7CtTzPm4J+DXEQJu6QCgkBh98I5HRkma+2TcSUzuDj8vBeoAn1v7
OFijDcduT7aHCPj/e4jhEAiz
=QTBu
-----END PGP SIGNATURE-----
Received on 2004-12-20