I want to upload image files using blobstore API using AJAX POST and not as html form submission. Based on Google search, i figured out that this could be done by uploading the image file to Google Cloud Storage using blobstore API. I went through this link but I am not able to understand it.
I have an html input element of type "file":
Pic <input type="file" name="pic" id="pic_file">
Name <input type="text" name="name" id="name">
Email <input type="text" name="email" id="email">
I have an AJAX call to send other input field values to my python backend:
var user_data = "&name="+$("#name").val() + "&email="+$("#email").val();
$.post("/admin", user_data, after_edit);
In my python file,
class Admin(BaseRequestHandler):
def get(self):
::
template_values = { 'url': url, }
self.generate('adminpage_1.html', template_values);
def post(self):
name = self.request.get('name')
email = self.request.get('email')
app = webapp2.WSGIApplication([
('/', MainHandler),
('/admin', Admin),
], debug=True)
I want to avoid using additional plugins for this if there is a way out without them