curl-and-php
Re: Using php/curl to send a file to HTTPS via post
Date: Tue, 8 Aug 2006 11:10:02 -0500
On 7/26/06, Aaron Axelsen <lists_at_frozenpc.net> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> I am trying to use PHP to post a file to a HTTPS link. It works from
> the command line using the following command:
>
> curl -s -F file=\@/path/to/my/file https://path/to/my/server
>
> I am having trouble try to replicate this same command using the
> php. Any suggestions?
>
> // Build Post Fields
> $postfields = array("file" => "@$fileIn"); // Full system path to the
> file
>
> $pushUrl = curl_init($uploadUrl);
> curl_setopt($pushUrl, CURLOPT_VERBOSE, 1);
> curl_setopt($pushUrl, CURLOPT_FAILONERROR, 1);
> curl_setopt($pushUrl, CURLOPT_FOLLOWLOCATION, 1);// allow redirects
> curl_setopt($pushUrl, CURLOPT_RETURNTRANSFER, true);
> curl_setopt($pushUrl, CURLOPT_POST, true);
> curl_setopt($pushUrl, CURLOPT_POSTFILEDS, $postfields);
> $output = curl_exec($pushUrl);
> $error = curl_error($pushUrl);
> $http_code = curl_getinfo($pushUrl ,CURLINFO_HTTP_CODE);
>
> curl_close($pushUrl);
>
> print "<br/>";
> print $http_code;
> print "<br /><br />$output";
> if ($error) {
> print "<br /><br />$error";
> }
You need this, I think
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
-- -----BEGIN GEEK CODE BLOCK----- Version: 3.12 GS/S d- s: a-29 C++(+++) ULAHI+++ P+ L++>+++ E--- W++ N* o-- K- w++++ O- M-- V-- PS+ PE Y-- PGP++ t- 5- X+ R tv++ b+ DI+++ D- G++ e++ h+ r+ z** ------END GEEK CODE BLOCK------ _______________________________________________ http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-phpReceived on 2006-08-08