cURL / Mailing Lists / curl-users / Single Mail

curl-users

How do I post a file from command line

From: David Hounsome <hounsome.david_at_googlemail.com>
Date: Wed, 22 Apr 2009 11:01:07 +0100

I'm a curl newbie and I want to start by saying "curl rocks!"

now to my question....

I need to communicate with a piece of hardware running a webserver,
from a linux command line.

Using curl I've managed to retrieve the hardwares status stored on an
html page and also download its current configuration in the form of a
xml file accessable via the web server. However I'm unable to upload a
new configuration file to it. The configuration file is normally
uploaded via a web page form.

I've found the source code on the web server that allows file upload and it is:

<form target="resultFrame" action="tcf" method="post"
enctype="multipart/form-data" name="frm_download">
<input type="hidden" value="dcp" name="cgi"/>
<input type="hidden" value="set" name="method"/>
<input type="hidden" value="/" name="path"/>
<input type="hidden" value="text/html" name="content"/>
<strong>File: </strong>
<input type="file" size="45" value="File" name="localfile"/>
<input type="submit" onclick="updateStatus()" value="Upload" name="download"/>
</form>

The file i wish to upload (tcf.xml) is local to where I'm running the
linux command line from so i constructed the following curl command:

 curl -v -i -F localfile=@tcf.xml -F "download=Upload" http://10.90.5.70/tcf

which gave me this in response

* About to connect() to 10.90.5.70 port 80
* Trying 10.90.5.70... connected
* Connected to 10.90.5.70 (10.90.5.70) port 80
> POST /tcf 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: 10.90.5.70
> Accept: */*
> Content-Length: 7114
> Expect: 100-continue
> Content-Type: multipart/form-data; boundary=----------------------------eb5e77766c8c
>
< HTTP/1.0 408 Request Timeout
HTTP/1.0 408 Request Timeout
< Content-type: text/html
Content-type: text/html
< Server :Tandberg Television Web server
Server :Tandberg Television Web server

Closing connection #0
<HTML><HEAD><TITLE>408 Request Timeout</TITLE></HEAD><BODY><H1>408
Request Timeout</H1>Your browser did not complete it's
request<P></BODY></HTML>

I was expecting to see the tcf.xml file contents in the out-going post
request so I thought maybe it wasn't looking at the right file, but i
noticed the content-Length looks about right.

Any help as to how to get this working would be greatly appreciated,
my project deadline is looming and putting files back to the hardware
device is the last thing I need to get done.

Many thanks

Dave
-------------------------------------------------------------------
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 2009-04-22