我正在尝试在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?该死的!请主持人删除问题,如果他们不想保留它