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

curl-and-php

Re: CURL running form PHP exec() problem!

From: Harry Fearnley <Harry.Fearnley_at_eng.ox.ac.uk>
Date: Mon, 11 Apr 2005 10:49:12 +0100

James Lu wrote:

> I want to post file through form use CURL like this
>
> /usr/bin/curl -k -s -S --connect-timeout 5 -F "interface=xxx" -F "option=xxx" -F "upload=@/tmp/upload" https://localhost:3444/upload.cgi
>
> in 3th -F option ,I want to upload the /tmp/upload file,so i used the @ sign.when I run it in the command console,anything is OK! But when I Call it from PHP's exec(),it do nothing and return value is not 0 but 26,when i drop the @ sige ,it can work ,but just the content of"/tmp/upload". Idon't know the reason, PHP or Curl problem? thanks

Daniel Stenberg suggested:

> Perhaps you need to escape the @-letter somehow?

I found that the "@" worked only when I was already in the directory containing
the file -- in other words the file name must not include any path.

I therefore do a "cd whatever" before I issue the curl command.

Another possible gotcha -- via PHP your username will probably be "apache" --
you may have done your command line tests as another user? I had what may be a
related problem -- when I was doing debugging I found that if I had an existing
debugging output file this would cause my upload to fail -- it was not enough
that user "apache" was the owner of the file and had write permission!

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 2005-04-11