如何在不提交html表单的情况下通过AJAX调用在GAE Python NDB中上载文件
我想上传图像文件使用BlobstoreAPI使用AJAX POST,而不是作为html表单提交。基于谷歌搜索,我发现这可以通过使用BlobstoreAPI将图像文件上传到谷歌云存储来实现。我看了一遍,但不明白 我有一个文件类型的html输入元素:如何在不提交html表单的情况下通过AJAX调用在GAE Python NDB中上载文件,python,ajax,google-app-engine,google-cloud-storage,blobstore,Python,Ajax,Google App Engine,Google Cloud Storage,Blobstore,我想上传图像文件使用BlobstoreAPI使用AJAX POST,而不是作为html表单提交。基于谷歌搜索,我发现这可以通过使用BlobstoreAPI将图像文件上传到谷歌云存储来实现。我看了一遍,但不明白 我有一个文件类型的html输入元素: Pic <input type="file" name="pic" id="pic_file"> Name <input type="text" name="name" id="name"> Email <input
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">
在我的python文件中
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)
如果没有其他插件,我想避免使用其他插件可能重复感谢Jimmy的参考,但如前所述,我宁愿不使用任何插件。参考答案使用Plupload pluginHere是一个示例说明:Blobstore和Google云存储GCS是两种用于保存Blob的不同技术。如果你刚刚开始学习应用程序引擎,那么就忘了GCS,直接使用Blobstore吧,谢谢Lipis的链接;我找不到太多关于如何使用它的文档,因为他们的文档链接还没有准备好。。
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)