I have in my view one input type "file", so I would like to get this file with jquery and send to my controller in Laravel, but, I don't see this file in debug
<form onSubmit="return false;" method="post" id="myForm" enctype=“multipart/form-data”>
@csrf
<label for="input-file-max-fs">Foto do perfil</label>
<input type="file" name="foto" id="foto" class="dropify @error('foto') is-invalid @enderror" data-max-file-size="3M" />
</form>
in the JS
$('.update).on('click', function() {
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
var dados = {
foto: $('input[name=foto]').val(),
.....
}
$.ajax({
method: 'PUT',
dataType: 'JSON',
url: '../perfil/editarusuario/',
data: dados,
success: function(res) {
console.log(res);
}
});
})
and in my Controller I trying to get the file, but no success
$file = $request->file('foto');
$file = $request->hasFile('foto')
$file = $request->file('foto')->isValid()
none of theses work