Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/google-app-engine/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Blobstore上传&x2B;Ajax/Alternative_Ajax_Google App Engine_Blobstore - Fatal编程技术网

Blobstore上传&x2B;Ajax/Alternative

Blobstore上传&x2B;Ajax/Alternative,ajax,google-app-engine,blobstore,Ajax,Google App Engine,Blobstore,下面的代码工作得很好。我唯一关心的是我想在下面转换成AJAX/alternative,这样就不需要刷新整个页面来提交这个请求 如有可能,还应包括加载进度条等 <form action="{{ upload_url }}" method="POST" enctype="multipart/form-data"> Upload File: <input type="file" name="file"> <br> <inpu

下面的代码工作得很好。我唯一关心的是我想在下面转换成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>

上传文件:

看看一些用于AJAX上传的JS解决方案——具体来说,Plupload可以连接到应用程序引擎blobstore,为您提供多上传支持、AJAX上传以及上传小部件/进度条等选项

事实上,有一个完整的步骤指导你

其要点是:

1) 下载并安装

2) 创建一个返回生成的上载URL的处理程序。大概是这样的:

from google.appengine.ext import webapp
from google.appengine.api import blobstore

class BlobstoreURLResponder(webapp.RequestHandler):

    """ Mapped to the URL /get_upload_url """

    def get(self):
        self.response.headers['Content-Type'] = 'text/plain'
        self.request.out.write(blobstore.create_upload_url('/blobstore/passthrough'))
3) 在上传文件之前,连接Plupload以获取blob上传URL

uploader.bind('UploadFile', function(up, file) {
    $.ajax({
        url: '/get_upload_url',
        async: false,
        success: function(data) {
          up.settings.url = data;
        },
    });

有关更详细的说明,请查看该博客文章。Nick有一个很棒的演练,它确实帮助我建立了Plupload+Blobstore。

检查。@Nick Johnson,很抱歉没有打问号。@Kevin p,谢谢!我很感激。