cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: Problem with Curl on Post - indicates Ok but file does not get uploaded

From: Ralph Mitchell <ralphmitchell_at_gmail.com>
Date: Thu, 3 Jul 2008 13:30:23 -0500

On Thu, Jul 3, 2008 at 1:17 PM, Brendan Lally <thelal_at_iname.com> wrote:

> New to CURL
>
> following example at
> http://www.sitepoint.com/article/uploading-files-cgi-perl
>
> Have it running fine via browser and get files uploaded ok
> When run CURL it indicates its working ok (get Apache code 200 back) but
> fails to get the file uploaded and I get a copy of the HTML script?
>
> no errors in error log
>
> Ta
>
>
> Command i'm using is :
> curl -F fn=@x.txt -F submit=OK -v --show-error
> http://localhost/results/upload
>
> * About to connect() to localhost port 80
> * Trying 127.0.0.1... connected
> * Connected to localhost (127.0.0.1) port 80
> > POST /results/upload HTTP/1.1
> > User-Agent: curl/7.15.5 (i686-redhat-linux-gnu) libcurl/7.15.5
> OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5
> > Host: localhost
> > Accept: */*
> > Content-Length: 4601
> > Expect: 100-continue
> > Content-Type: multipart/form-data;
> boundary=----------------------------89df32cc7c79
> >
> < HTTP/1.1 100 Continue
> < HTTP/1.1 200 OK
>
> < Date: Thu, 03 Jul 2008 17:22:09 GMT
> < Server: Apache
> < Last-Modified: Thu, 03 Jul 2008 16:39:23 GMT
> < ETag: "5128ba9-271-406564c0;9b975740"
> < Accept-Ranges: bytes
> < Content-Length: 625
> < Content-Type: text/html; charset=UTF-8
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
> "DTD/xhtml1-strict.dtd">
> <!-- -->
> <!-- simple form to upload Files via Upload.cgi Perl script -->
> <!-- -->
> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
> <head>
> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
> <title>File Upload</title>
> </head>
> <body>
> <form action="/cgi-bin/upload.cgi" method="post"
> enctype="multipart/form-data">
> <p>File to Upload: <input type="file" name="fn" /></p>
> <p> <input type="submit" name="submit" value="OK" /></p>
> </form>
> </body>
> </html>
> * Connection #0 to host localhost left intact
> * Closing connection #0

You need to be posting to the form action url, not to the form page. In
other words:

     curl -F fn=@x.txt -F submit=OK -v --show-error
http://localhost/cgi-bin/upload.cgi <http://localhost/results/upload>

Ralph Mitchell

-------------------------------------------------------------------
List admin: http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-users
FAQ: http://curl.haxx.se/docs/faq.html
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2008-07-03