I am trying to sumbit a form in django that has a file on it. The form is the following and is placed in the body of a modal dialog
<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>
I have a button with id = upload and my js code looks as the following
$("#upload").on('click', function(){
form = $("#xrayform");
form.submit();
});
But the request.FILES is an empty dict. How is it not passing the files on the dictionary when posting?
EDIT: How about putting some enctype on the form you would say right?? Damn me!!! Please the moderators delete the question if they don't want to keep it