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

curl-and-php

curl upload error (23): command line OK -- exec from PHP fails ... !

From: Harry Fearnley <Harry.Fearnley_at_eng.ox.ac.uk>
Date: Fri, 27 Aug 2004 17:16:17 +0100

Sorry for the chevrons -- I am fighting autowrap!

> curl upload error (23): command line OK -- exec from PHP fails ... !
> ====================================================================
>
>
> I can upload a 4+ Mb file OK from my linux command line using curl.
>
> However, when I execute the same command from PHP using backtick
> quotes it fails. If I try to do the same thing using a call to
> exec from PHP, it fails also. (BTW, and probably obviously! --
> if, on the linux box, I put the curl commands into a script, and
> execute the script, it succeeds just as it did at the command line).
>
> Needless to say, I have never succeeded in doing this exercise
> using the libcurl PHP interface ... :-(
>
> Can anyone help, or should I start again from scratch and use
> HTTPNavigator (partial implementation of LWP in PHP)?!
>
>
> Details of the problem follow:
>
> The scenario:
>
> I have already had 2 interactions with the server to which I want
> to upload, and have the appropriate cookie set OK.
>
> Here is the command line (formatted to improve legibility!):
>
> curl --insecure -b /home/syshf/public_html/PDF/cookies2.txt
> -c /home/syshf/public_html/PDF/cookies3.txt
> -o /home/syshf/public_html/PDF/wl_try_upload.html
> -F file=@1p12_Tut-Ans_1.PDF -F submit=Send%20Now
> https://www.weblearn.ox.ac.uk/bodington/site/mathsphys/engineering/cohort2003/eng/y1/mt/p1/1p12/bs_template_uploadrawconfirm.html
> > weblearn_upload.log 2>&1
>
> at the linux shell prompt this works results in several lines of
> output like:
>
> % Total % Received % Xferd Average Speed Time Curr.
> Dload Upload Total Current Left Speed
> 51 4694k 0 0 33 1584k 0 712k 0:00:06 0:00:02 0:00:04 834k
> 100 4694k 0 154 100 4694k 0 763k 0:00:06 0:00:05 0:00:00 814k
> 100 4694k 0 619 100 4694k 83 633k 0:00:07 0:00:07 0:00:00 539k
>
> -- works fine. I get the same result if I run a shell script.
>
>
> However, when I have the same command line in PHP, and do:
>
> exec ("$command", $output_array, $result);
>
> I get a result of 23, and the following output.
>
> % Total % Received % Xferd Average Speed Time Curr.
> Dload Upload Total Current Left Speed
> 48 4694k 0 0 31 1488k 0 706k 0:00:06 0:00:02 0:00:04 847k
> 100 4694k 0 0 100 4694k 0 760k 0:00:06 0:00:05 0:00:01 817k
> 100 4694k 0 0 100 4694k 0 763k 0:00:06 0:00:06 0:00:00 793k
> curl: (23) Failed writing body
>
>
> N.B. (a) It says that it has transferred 100% of the file -- it took several
> seconds, just as a successful transfer did. However it has uploaded
> only a pathetic 7803 bytes (same every time)
>
> (b) The received column is now uniformally zero!
>
> (c) The last line reports an error result of 23.
>
>
> I get the same result when I use backtick, and do
>
> $r3 = `$command`;
>
>
>
> All help would be gratefully received. If you need more informationm, or want me
> to do more tests, please ask.

Thanks in advance.

Harry

+-+-+-+-+.+-+-+-+-+.+-+-+-+-+.+-+-+-+-+.+-+-+-+-+.+-+-+-+-+.+-+-+-+-+.+-+-+-+-+-
http://www.eng.ox.ac.uk/people/Harry.Fearnley
Dept Engineering Science, Parks Rd, Oxford, OX1 3PJ, UK
Tel: +44 (0)1865 273928 -- Fax: +44 (0)1865 273010
Received on 2004-08-27