1

我正在尝试在 django 中汇总一个包含文件的表单。形式如下,放置在模态对话框的主体中

<form action="{%url 'customer-upload-xray' customer_id=customer_id%}" method="post" id="xrayform">
    {%csrf_token%}        
    <div class="form-group date">
        <label for="id_date">Date</label>
        <input class="form-control input-sm datepicker input-append date" id="id_date" name="date" readonly="" type="text">
    </div>
    <div class="form-group">
        <label for="id_type">Type</label>
        <select class="form-control input-sm" id="id_type" name="type">
            <option value="" selected="selected">---------</option>
            <option value="Observation">Observation</option>
            <option value="Initial">Initial</option>
            <option value="Progress">Progress</option>
            <option value="Final">Final</option>
            <option value="Post Treatment">Post Treatment</option>
        </select>
    </div>
    <div class="form-group">
        <label for="id_desc">Desc</label>
        <select class="form-control input-sm" id="id_desc" name="desc">
            <option value="PA Ceph">PA Ceph</option>
            <option value="Lateral Ceph">Lateral Ceph</option>
            <option value="Panoramic">Panoramic</option>
        </select>
    </div>
    <div class="form-group">
        <label for="id_image1">Image1</label>
        <input id="id_image1" name="image1" type="file">
    </div>
    <div class="form-group">
        <label for="id_image2">Image2</label>
        <input id="id_image2" name="image2" type="file">
    </div>
                    \
</form>

我有一个 id = upload 的按钮,我的 js 代码如下所示

$("#upload").on('click', function(){
    form = $("#xrayform");
    form.submit();

});

但是 request.FILES 是一个空字典。发布时如何不传递字典上的文件?

编辑:在你会说对的表格上放一些 enctype 怎么样?该死的我!!!请版主删除问题,如果他们不想保留它

4

0 回答 0