Blobstore 上传 +阿贾克斯/替代方案
下面的代码可以完美运行。我唯一关心的是我想将下面的内容转换为 AJAX/alternative,这样就不需要刷新整个页面来提交此请求。
如果可能的话,还包括加载进度条等。
<form action="{{ upload_url }}" method="POST" enctype="multipart/form-data">
Upload File: <input type="file" name="file"> <br>
<input type="submit" name="submit" value="Submit">
<input type="hidden" name="data1" value="{{ data1 }}">
<input type="hidden" name="data1" value="{{ data2 }}">
</form>
The following code works perfectly. My only concern is that I wanna convert below to AJAX/alternative, so that it doesn't need to refresh the whole page to submit this request.
If possible, to also include loading progress bar etc.
<form action="{{ upload_url }}" method="POST" enctype="multipart/form-data">
Upload File: <input type="file" name="file"> <br>
<input type="submit" name="submit" value="Submit">
<input type="hidden" name="data1" value="{{ data1 }}">
<input type="hidden" name="data1" value="{{ data2 }}">
</form>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看一下一些用于 AJAX 上传的 JS 解决方案 - 具体来说,Plupload 可以连接到 App Engine blobstore,为您提供多重上传支持、AJAX 上传以及上传小部件/进度条等选项。
事实上,@NickJohnson 拥有完整的博客文章 指导您完成步骤。
其要点是:
1) 下载并安装 Plupload
2) 创建一个返回生成的上传 URL 的处理程序。像这样的事情:
3) 在上传文件之前连接 Plupload 以获取 blob 上传 URL
有关更详细的说明,请查看该博客文章。 Nick 有一个非常棒的演练,它绝对帮助我设置了 Plupload + Blobstore。
Take a look at some JS solutions for AJAX upload - specifically, Plupload can be hooked up to work with the App Engine blobstore, giving you multiupload support, AJAX upload, and options for upload widgets/progress bars/etc.
In fact, @NickJohnson has a full blog post guiding you through the steps.
The gist of it is:
1) Download and install Plupload
2) Create a handler that returns a generated upload URL. Something like this:
3) Hook up Plupload to get a blob upload URL before uploading a file
For more detailed instructions, take a look at that blog post. Nick has an awesome walkthrough that definitely helped me get set up with Plupload + Blobstore.