Need help processing upload form with Google App Engine Blobstore

故事扮演 提交于 2019-12-01 21:29:02

The problem is that your posted form data is lost when you redirect the request to "/save/%s", which is normal.

Instead of redirecting, you should put your code inside UploadHandler, like this (untested code) :

class UploadHandler(blobstore_handlers.BlobstoreUploadHandler):
    def post(self):
        try:
            upload_files = self.get_uploads('file')
            blob_info = upload_files[0]

            newFile = StoredFiles()
            newFile.nickname = self.request.get('nickname')
            newFile.blobkey = blob_info.key()
            newFile.put()

            self.redirect('/')
        except:
            self.redirect('/upload_failure.html')

See this page from the docs for a similar example : http://code.google.com/appengine/docs/python/tools/webapp/blobstorehandlers.html#BlobstoreUploadHandler

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!