1 回答

TA貢獻(xiàn)1862條經(jīng)驗(yàn) 獲得超6個(gè)贊
它不允許您存儲(chǔ)文件,因?yàn)槲募o法發(fā)送到服務(wù)器,因?yàn)槟褂?AJAX 發(fā)出請(qǐng)求,要通過 AJAX 發(fā)送文件,請(qǐng)嘗試以下操作:
$('#servicio_form').on('submit', function(event){
event.preventDefault();
// init formData and get files
let formData = new FormData($('#servicio_form')[0]);
let imagenInicio = $('#imagen_inicio')[0].files[0];
let imagenFin= $('#imagen_fin')[0].files[0];
let pdfReporte= $('#pdf_reporte')[0].files[0];
// append files to formData
formData.append('imagen_inicio', imagenInicio);
formData.append('imagen_fin', imagenFin);
formData.append('pdf_reporte', pdfReporte);
// in AJAX disable contentType, processData and cache
$.ajax({
url:"{{ route('mis-servicios.postdata') }}",
method:"POST",
dataType:"json",
data: formData, // change this and the following options
contentType: false,
processData: false,
cache: false,
success: function(data) {
// your code...
}
});
});
- 1 回答
- 0 關(guān)注
- 262 瀏覽
添加回答
舉報(bào)