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

curl-and-php

PHP, PUT and cUrl to another server

From: Julian Bond <julian_bond_at_voidstar.com>
Date: Thu, 8 Jun 2006 12:15:52 +0100

PHP 4.4.0, libcurl/7.11.2 OpenSSL/0.9.7g zlib/1.1.4

I'm having trouble making PUT file work with cUrl from PHP to another
server.

 From the command line, this works:-
$ curl --user user:password --upload-file blogs.csv
http://remoteserver.com/put2q/update/blogs/blogs.csv/TESTING

Ignore the specifics of the URL, they've been mangled.

In PHP I have this code snippet

$localfile = "blogs.csv";
$ch = curl_init();
$url = "http://remoteserver.com/put2q/update/blogs/blogs.csv/TESTING";
curl_setopt($ch, CURLOPT_USERPWD, 'user:password');
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_UPLOAD, 1);
curl_setopt($ch, CURLOPT_READDATA, $localfile);
curl_setopt($ch, CURLOPT_INFILESIZE, filesize ($localfile));
$result = curl_exec($ch);
$error = curl_error($ch);
curl_close($ch);

This code just appears to hang. The browser never comes back until PHP
times out.

Do the curl_setopt parameters correctly correspond with the command line
version? How do I go about debugging this? I'm happily using curl inside
PHP from the same installation and with the same remote server to do
things like collect XML so I think the installation is ok.

-- 
Julian Bond  E&MSN: julian_bond at voidstar.com  M: +44 (0)77 5907 2173
Webmaster:           http://www.ecademy.com/     T: +44 (0)192 0412 433
Personal WebLog:     http://www.voidstar.com/    skype:julian.bond?chat
                     *** Just Say No To DRM ***
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2006-06-08