I'm trying to add another parameter using a hidden input:
$('#form1').submit(function(){ //listen for submit event
$('<input />').attr('type', 'hidden')
.attr('name', 'id')
.attr('value', id)
.appendTo('#form1');
return true;
});
"id" is a global variable.
My HTML form:
<form id="form1" method=POST runat="server" enctype='multipart/form-data' action="/set_image">
<div class="fileButtons">
<input type='file' id="imgInp" name="imgInp" accept="image/*"/>
<input type='button' id='remove' name="remove" value='Remove' />
</div>
<br>
<div class="modal-footer">
<a type="button" class="btn pull-left" data-dismiss="modal">Cancel</a>
<button type="submit" class="btn btn-primary pull-left">OK</button>
</div>
</form>
In the log console of Google app engine, I can see that only "id" gets its value.
In firebug, it shows while debugging:
imgInp
input#imgInp property value = "2.jpg" attribute value = "null"
main.py:
class SetImage(webapp2.RequestHandler):
def post(self):
id = str(self.request.get('id'))
image = str(self.request.get('impInp'))
...
app = webapp2.WSGIApplication([ ('/set_image', SetImage),
('/', MainPage)], debug=True)
I used the post in here:
https://stackoverflow.com/a/993897/2653179
Edit: The problem was solved, it was a typo in the imgInp variable in SetImage class...