cURL / Mailing Lists / curl-users / Single Mail

curl-users

AW: Trouble with a form

From: <Alexander.Elgert_at_t-systems.com>
Date: Wed, 23 May 2012 23:21:14 +0200

Hmm, you have to respect the fact, that $ is a metacharacter of the shells and protect it from evaluation.
On bash please put the parameter using $ in single quotes:
curl -k --cookie my-cookies --form 'ctl00$ContentPlaceHolderMain$File=@file-to-upload' --form do_button_press_here

# echo 'ctl00$ContentPlaceHolderMain$File=@file-to-upload'
ctl00$ContentPlaceHolderMain$File=@file-to-upload
# echo "ctl00$ContentPlaceHolderMain$File=@file-to-upload"
ctl00=@file-to-upload
#

Then you have to do simulate the button press, but it is done in javascript, maybe you can just do a
--form press=ok
which hopefully may just do the submit, even if the button is missing.

http://curl.haxx.se/docs/httpscripting.html
section 4.3

I would suggest you to use webscarab as a proxy in the middle, to see what happens exactly.
Then you are able to compare the requests of the curl and the browser client more easily.

Greetings,
Alexander

--
Deutsche Telekom AG
Seamless ICT Security Infrastructure & Management
im Auftrag T-Systems International GmbH
Dipl. Inf Alexander Elgert
Langwadener Strasse 17
64625 Bensheim
+49 176 22 717 661 (Mobil)
+49 671 83419-12 (Tel)
+49 671 83419-30 (Fax)
E-Mail: alexander.elgert_at_gmx.de
________________________________________
Von: curl-users-bounces_at_cool.haxx.se [curl-users-bounces_at_cool.haxx.se] im Auftrag von Bill Mercer [bmercer_at_nccer.org]
Gesendet: Mittwoch, 23. Mai 2012 18:32
An: Gary; the curl tool
Betreff: RE: Trouble with a form
>I'm having trouble getting curl to submit a form designed to upload a
>file. I know basically what I should be doing, but can't seem to get
>the details right, the server just presents the same form back as a
>response.
Not having all the code I can't be sure, but if this is the upload.aspx page,
then I'd expect it to return to the form after processing the upload.
Have you checked to see if the upload is happening?
What happens when you manually upload a file using this same form?
>The form is as follows (edited down to the basics):
><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
>
><html xmlns="http://www.w3.org/1999/xhtml">
><head></head>
><body>
>  <div>
>    <form name="aspnetForm" method="post" action="upload.aspx"
>id="aspnetForm" enctype="multipart/form-data">
>      <input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET"
>value="" />
>      <input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT"
>value="" />
>
>      <input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE"
>value="/SOME_SECRET_VALUE" />
>      <script type="text/javascript">
>      //<![CDATA[
>      var theForm = document.forms['aspnetForm'];
>      if (!theForm) {
>      theForm = document.aspnetForm;
>      }
>      function __doPostBack(eventTarget, eventArgument) {
>      if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
>        theForm.__EVENTTARGET.value = eventTarget;
>        theForm.__EVENTARGUMENT.value = eventArgument;
>        theForm.submit();
>      }
>      }
>      //]]>
>      </script>
>      <input type="hidden" name="__EVENTVALIDATION"
>id="__EVENTVALIDATION" value="/ANOTHER_SECRET_VALUE" />
>
>      <a id="ctl00_ContentPlaceHolderMain_Save" class="button"
>href="javascript:__doPostBack('ctl00$ContentPlaceHolderMain$Save','')"
>name="ctl00_ContentPlaceHolderMain_Save">Save</a>
>
>      <p>File: <input type="file"
>name="ctl00$ContentPlaceHolderMain$File"
>id="ctl00_ContentPlaceHolderMain_File" /></p>
>    </form>
>  </div>
></body>
></html>
>
>I tried separate --form arguments for each "input". Is that correct?
>Something like:
>  curl -k --cookie my-cookies --form
>ctl00$ContentPlaceHolderMain$File=@file-to-upload --form ...
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ:        http://curl.haxx.se/docs/faq.html
Etiquette:  http://curl.haxx.se/mail/etiquette.html
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ:        http://curl.haxx.se/docs/faq.html
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2012-05-23