I'm trying to send an UIImage and some extra parameters through POST.
I've tried the answer to this question with no success:
The HTML form equivalent would be the following (it works):
<form method="POST" action="UploadURL" enctype="multipart/form-data">
<input type="file" name="pic">
<input type="submit" value="upload">
<input type="hidden" name="param1" value="param1value"/>
<input type="hidden" name="param2" value="param2value"/>
</form>
Thanks in advance.
I've just wasted so many hours... It seems that the people I've been working with gave me a wrong URL, which gives the same response for anything. I've just wasted so many hours on this.
Please refer to this question for a good answer for uploading images using POST request.
Related
I have an URL. There is a form in that URL and I know it's name and the form action.
E.g:
url:
www.abc.com/123.html
form:
<form action="POST.php" method="post" name="form">
<input id="id" name="name" type="text">
</form>
My question is how do I post this form and get the response? I have tried several answers but they didn't work well. Any programming language is fine.
this can be done in PHP.
see this Submitting form to remote server.
I was working on a webbot and I came across this strange page where multiple variables had the same name but different values in as shown by the Firefox web console. I am not sure as to how I can replicate this behavior in python. Currently, I am using the requests library to make post requests and that takes in a dictionary of name and value pairs. And of course, dictionaries have unique keys. So I was wondering if anyone could tell me how to send post requests with multiple variables carrying the same name.
sel_subj:dummy
sel_subj:ECE
Thanks,
Rajiv
Edit: Here is the html source that causes this
<input type="hidden" value="dummy" name="rsts"></input>
<input type="hidden" value="dummy" name="crn"></input><br></br>
<input type="hidden" value="120138" name="term_in"></input>
**<input type="hidden" value="dummy" name="sel_subj"></input>**
<input type="hidden" value="dummy" name="sel_day"></input>
<input type="hidden" value="dummy" name="sel_schd"></input>
<input type="hidden" value="dummy" name="sel_insm"></input>
<input type="hidden" value="dummy" name="sel_camp"></input>
<input type="hidden" value="dummy" name="sel_levl"></input>
<input type="hidden" value="dummy" name="sel_sess"></input>
<input type="hidden" value="dummy" name="sel_instr"></input>
<input type="hidden" value="dummy" name="sel_ptrm"></input>
<input type="hidden" value="dummy" name="sel_attr"></input>
<table class="dataentrytable" summary="Table is used to present the course search criteria">
<tbody>
<tr>
<td class="delabel" scope="row"> … </td>
<td class="dedefault" colspan="37">
**<select id="subj_id" multiple="" size="10" name="sel_subj"> …
</select>**
</td>
</tr>
</tbody>
</table>
Notice how the select tag and the highlighted input tag have the same name.
The only method that I know is using a variable-name appended with [].
<input type="hidden" value="dummy" name="sel_subj[]"></input>
<input type="hidden" value="ECE" name="sel_subj[]"></input>
This results in an array placed in $_POST['sel_subj'], with $_POST['sel_subj'][0] being "dummy" and $_POST['sel_subj'] being ECE.
Now as I think of it, I think the creation of the array is done by the php-parser when there is a [] attached. This suggests that both values are send through the POST even if there is not [] at the end of the name. Maybe PHP can be configured not to dismiss this values.
In case of GET variables (in the url), you can have multiple values with the same name. You can just parse the entire url and read and use every value.
PHP even solves this automatically if you add [] to the name of the parameter. In that case, it automatically changes it into an array. But this is a trick as well. It is fairly easy to write a piece of code that does the same thing with duplicate names without them having [] as a postfix.
They same will happen post variables as well. You just might need a little more code to read them properly.
The code in this case probably checks if there is sel_subj with any value other than dummy. If that is the case, then that value is used. If it doesn't exists, sel_subj may still exist with the value dummy. That is probably an indication for the script that the form was posted, but no value was selected.
So actually, I think it's quite easy to explain how this script works, and probably even why, but I don't think it's a very good solution to put all defaults in hidden fields this way, so I would suggest you don't try to replicate this solution. :-)
can some one help me please.
how can I add 1 more input to YUI POST CONNECTION
Here is the tutorial: http://developer.yahoo.com/yui/examples/connection/post.html
And the default sample form is: <form><input type="button" value="Send a POST Request" onClick="makeRequest();"></form>
How can I add one more input like that:
<form>
<input type="text" name="username">
<input type="button" value="Send a POST Request" onClick="makeRequest();">
</form>
I want to send username input request too.
Thank you !!
The example you reference builds the POST request body manually. While you can certainly do this, you might find it easier to use the setForm method of the Connection Manager (example here). It will include all the form fields and take care of the URL encoding for you.
I would like to add simple site search, using Duckduckgo, limited to search only "example.com".
Stackoverflow has solved this, using some JavaScript to add the site:example.com filter to the query.
<form onsubmit="var txt=$(this).find('input[name=\'q\']'); txt.val(txt.val() + ' site:stackoverflow.com');" action="http://www.duckduckgo.com/" method="get" id="duck-duck-go-search">
<input type="text" value="" maxlength="255" size="36" name="q">
<input type="submit" value="DuckDuckGo">
</form>
I'd prefer a solution that does not depend on JavaScript, though.
The URL should be http://duckduckgo.com/?q=site:example.com%20might; the site:example.com must be added to the q= parameter, it seems.
Has anyone found a simple, non JavaScript solution for this?
I contacted DuckduckGo and got a solution from Weinberg himself.
There actually is a hidden sites param :). Try it!
Gabriel, http://ye.gg
It was the plural (not site, but sites) that got me confused, but the solution is very simple:
http://duckduckgo.com/?q=duckduckgo& sites= stackoverflow.com
Or, in a simple HTML form:
<form action="https://duckduckgo.com/" method="get">
<input type="hidden" name="sites" value="stackoverflow.com">
<input type="search" name="q">
<input type="submit" value="Search">
</form>
I've looked all over paypal's website and can't find any info on creating a simple text link for a donation.
Anyone have any info?
According to this link, you can use HTTP GET, meaning you can build a URL for a simple link.
Note that this link is written in C#, so you can't actually use this as code reference.
You'll probably need something like
<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=email#myserver.com&item_name=...">
Make sure to use '&' to separate fields and to encode them properly if they include special characters (such as '&').
Updating the button code from paypal:
<form name="_xclick" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="me#mybusiness.com">
<input type="hidden" name="item_name" value="Team In Training">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="amount" value="25.00">
Donate
</form>