curl-users
RE: Trouble with a form
Date: Wed, 23 May 2012 16:32:00 +0000
>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
Received on 2012-05-23