I have this little set of Python code on the GAE, trying to upload an image to the datastore:
class UploadPage(webapp.RequestHandler):
def get(self):
self.response.out.write("""<html><body>
<form action="/addimg" enctype="multipart/form-data" method="post">
<div><label>Project Name</label></div>
<div><textarea name="title" rows="2" columns "60"></textarea></div>
<div><label>Despcription:</label></div>
<div><textarea name="content" rows="3" cols="60"></textarea></div>
<div><label>Image</label></div>
<div><input type="file" name="img"/></div>
<div><input type="submit" value="Upload" /></div>
</form>
</body>
</html>""")
class addimg(webapp.RequestHandler):
def post(self):
images = ImgUpload()
imgtitle = self.request.get('title')
imgcontent = self.request.get('content')
headpic = self.request.get('img')
images.headpic = db.Blob(headpic)
images.imgtitle = imgtitle
images.imgcontent = imgcontent
images.put()
self.redirect('/upload')
When you go to the site, hit submit, it goes to the addimg and stops and doesn’t complete the put or redirect, I am not sure where I may have missed it, any guidance is very appreciative.
I switched the addimg to a POST under the UploadPage, and it worked, not sure why it didnt work when coming frmo a class though