<form class="upload-form" enctype="multipart/form-data" >
<div class="file-field">
<input type="file" name="upload-file" id="real-file" hidden="hidden" multiple/>
<input type="hidden" class="csrf" name="<?= $csrf["name"]; ?>"
value="<?= $csrf["hash"]; ?>"/>
<button type="button" id="buttonUpload" class="btn btn-info block-center">Добавить файл</button>
<div class="file-path-wrapper">
<span id="custom-upload-text">Файл не выбран.</span>
</div>
</div>
</form>
сам запрос
$('#sendUpload').on('click', function (e) {
var formUpload = $(".upload-form")[0];
e.preventDefault();
let formUploadData = new FormData( formUpload );
/* let uplres = {
formUploadData, 'order_id': $('#orderId').text()
};*/
$.ajax( {
url: '/vip/form_upload',
type: 'POST',
data: formUploadData ,
processData: false,
contentType: false,
success: function (res) {
$('.csrf').val(res.csrf);
$('#upload-count').html('(' + uploadCount + 1 + ')');
alert(res);
}
});
});
на текущем этапе получаю 415 (Unsupported Media Type)
когда добавляю
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
то не срабатывает csrf