request.Files返回空列表

时间:2012-10-27 08:58:07

标签: jquery django twitter-bootstrap multi-upload

尝试在我的django应用程序中使用JQuery插件上传多个文件(使用引导程序) - https://github.com/blueimp/jQuery-File-Upload

但我遇到了一个问题,在views.py中调用了“上传按钮”的方法。我收到了文件的空列表。

我在views.py中的代码: -

def multiuploader(request):
    if request.method == 'POST':
        print 'received POST to main multiuploader view'
        if request.FILES == None:
            return HttpResponseBadRequest('Must have files attached!')
        print 'files'
        print request.FILES

在控制台中我得到:

received POST to main multiuploader view 
files 
<MultiValueDict: {}>

html文件: -

<div id="fileupload">
<form action="{% url multi %}" method="POST" enctype="multipart/form-data">
  {% csrf_token %}
    <div class="fileupload-buttonbar">
        <label class="fileinput-button">
            <span>Add files...</span>
            <input type="file" name="files[]" multiple>
        </label>
        <button type="submit" class="start">Start upload</button>
        <button type="reset" class="cancel">Cancel upload</button>
    </div>
</form>
<div class="fileupload-content">
    <table class="files"></table>
    <div class="fileupload-progressbar"></div>
</div>

任何想法如何解决这个问题? 非常感谢advnace

0 个答案:

没有答案