0

尝试在我的 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>

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

4

0 回答 0