Nested Form Elements File size limit (Legacy code) - html

We have some really old code from which one part like 15k lines of code make a really old fashioned procedural form content menagment system.
Now here comes the stupid part. Whole code is based so it nests form elements. Wich is by definion wrong. we have code like
<form action="demo_post_enctype.asp" method="post" enctype="multipart/form-data">
First name: <input type="text" name="fname"><br>
Last name: <input type="text" name="lname"><br>
<input type="submit" value="Submit">
.
.
.
.
<form enctype="multipart/form-data">
<input type='File'>
</form>
</form>
Now this is only the teoretical layout. the whole thing is so complex and "uniquely" unprofesionally made that my head hurts.
The strange thing is it works, kinda, no idea how. And now we have a problem to upload files bigger then around 28mb. I checked the server settings it is set to 1gb upload size and it works without problems in the new refactored parts it works.
Question:
What is the effective upload size of such buggy code?
We need to give curent users the feedback while the old code gets refactored.

Although the code doesn't work as intended, it can still work in a sense. As nested forms are invalid, as far as I know all browsers will handle the problem by ignoring the starting tag for the inner form, and end the form at the ending tag of the inner form.
So, as long as the inner form is at the end of the outer form, it will be a single form containing all the fields, and will be posted to the action of the outer form.
While there will be some extra fields included when you upload a file, that would hardly account for so much data that the upload size would be noticably reduced. Perhaps it's the fact that the data is posted to a different page than intended that causes the problem.

Related

HTML Form as link is corrupting the adress

i assume this is a noob question, so sorry.
I'm trying to write this HTML-Page with a "form" that will work like a link on my raspberry pi.
So I used this code:
<form action="http://192.168.178.62/graph.pl?type=week">
<input type="submit" value="Blah" />
</form>
But instead of ending up at the adress I wrote in the code, I end up here: http://192.168.178.62/graph.pl? ("type=week" is missing, its just cut off)
Why is that, and how can I fix it?
thanks a lot!
When you submit a form with method="GET" (which is the default) then a new query string will be generated from the names and values of the successful form controls (since you don't have any, it will be empty). The new (empty) query string will replace the one in the action.
Options:
Use a link. (This is the best option. You aren't collecting any data from the user. You aren't making a POST request).
Move the data from the action to <input type="hidden" ...> elements.

MechanicalSoup 2 submit buttons in form, provide time for the first to exert its effect or not?

The online HTML-form I want to fill out using MechanicalSoup has 2 submit buttons (so 1 form with 2 submit buttons). The first button (red in the picture "Toevoegen") is to upload a photo after choosing a file. The second button (not shown) submits the completed form. I have figured out how to address the different buttons using the form.choose_submit() function, so that's fine.
My question now is the following:
When I fill the form by hand, I noticed that after selecting the file and pressing the first (red) button, it takes some time (1-2 secs) for the file to upload. When I now fill out the form using mechanical soup, do I have to include this time (1-2 secs) for the photo to upload (for example using the time.sleep()) before I (make MechanicalSoup) fill out the rest of the form and submit it using the second submit button? Or will the form figure out that it has to upload the pic first and wait for that before executing the final submit order? So it's really a timing issue I have to coordinate the proper functioning of both buttons...
I hope this edit clarifies things a bit more.
Thanks for any suggestions!!
If it helps: this is what I found in the HTML form for the first submit button:
<div id="edit-submitted-file_add-ajax-wrapper">
<div class="form-item webform-component webform-component-file webform-component--file_add">
<label for="edit-submitted-file_add-upload">Add File</label>
<div class="form-managed-file">
<input type="file" id="edit-submitted-file_add-upload" name="files[submitted_file_add]" size="22" class="form-file" />
<input class="button form-submit" type="submit" id="edit-submitted-file_add-upload-button" name="submitted_file_add_upload_button" value="Toevoegen" />
<input type="hidden" name="submitted[file_add][fid]" value="0" />
</div>
</div>
</div>
When submitting a file, the file upload is part of the form submission. There's no point waiting before submitting, because this is not when the file upload happens. Unless the website is seriously broken, there's no point waiting after either, because the .sumbit() method call is blocking, i.e. it returns only after the form submission, hence the file upload, is completed.
However, it's hard to tell what you should do exactly in your case: it seems the first submission is done without reloading the page, hence using JavaScript. MechanicalSoup does not do JavaScript, so it may or may not work (in a perfect world, sites that work through JavaScript have a non-JavaScript fallback, but ...).
Probably the best for you is to try and see what works.

Any way to force a form to submit fields differently without using Javascript?

I have a form:
<form method="GET">
<input type="text" value="hello" name="myname" />
</form>
If this form is submitted, I will end up at:
example.com/?myname=hello
What I would prefer is that when this gets submitted, I end up at:
example.com/hello
Is this possible?
No, you cannot change the way form submission works in HTML. (Using JavaScript, you can do transactions in a different way, without using HTML form submission.) When using method="GET", the URL gets constructed in a specific way; when using method="POST", the URL does not contain submitted data at all (it is sent outside the URL).
There is a trick that changes form submission in one way, but not quite the way you want. If the name of a control is isindex, then the control name and the equals sign are omitted; but the question mark is still there. That is, <input type="text" value="hello" name="isindex" /> would result in http://www.example.com/?hello. And Chrome has broken this when they removed the remainders of support to the isindex element.
If, for some special reason, you really need to make a form create requests like http://example.com/hello, then the simplest way is to set up a very simple server-side script that accepts normal requests that result from HTML forms and just passes them forward after modifying the URL in a simple way.

HTML Forms: Submit button that goes to querystring?

I'm working on a Rails site, and I've got my database indexed with IndexTank. I have things set up so that to search, all I have to do is browse to [root]/search?q=[query]. To simplify things, I'm planning on just dropping a HTML form with a textbox and a submit button in amongst the erb, but I'm not quite sure how to pass the information from the text box to the end of the /search?q= line.
I'm sure that this is terribly basic, but I've been Googling all morning and I've come up empty-handed.
<form action="/search">
<label>Search term <input name="q"></label>
<input type="submit">
</form>
First off, you'll probably need to post some more code. That said, the solution is likely as simple as setting your form element's method attribute to GET.

Change POST values in webpages? Riddle help?

I'm kinda new here and I've got a programming/coding related question you guys maybe could help me with. I'm currently playing this game on the net www.darker-future.nl which is sort of a site you got to hack/use IT knowledge to go up levels. I'm kinda stuck at this level which i obviously lack the knowledge of coding for?
Ive got this HTML source code in the page:
<form method='POST' action='**************.html'>
<input type=hidden name='40+b+c*d' value='2354'>
<input type=hidden name='a*30-c+d' value='8937'>
<input type=hidden name='a-b-20/d' value='3639'>
<input type=hidden name='a%b+c-10' value='3954'>
<input type=hidden name='a+b*c*d' value='9284'>
<input type=hidden name='a-b/c-d' value='6573'><!-- +0.5 -->
<input type=text name='a*b/c/d'><br>
<input type=submit>
</form>
I think i got to change the values from the hidden input boxes with the right answers or something. My question: How can I easily fake POST values?
PS. Any tips on maybe things i've forgot to think about in this level please share.
If you're using Firefox, get Firebug, open the HTML panel, and edit the value attribute. Simple.
Are you sure it wants you to change the POST values "in flight" as it were.
Surely you need to find the values of a, b, c and d based on the 6 equations it gives you (simultaneous equations), and put the resulting values into the seventh expression to generate a value.
Then enter this value into the text box and click submit.
Yes get the firebug extension for Firefox. After it's installed click the little bug icon in the bottom left corner. You can edit the HTML in the firebug window to change the values.
A more long winded solution would be to write some code to generate an HTTP Post request in the correct format.