0
Problem:
I am trying to send a form with ajax via PUT, but it is returning the following message on Chrome console:
PUT http://intranet.dev/%7B%7B%20URL::to('upload/'.Auth::user()-%3Eid)%20%7D%7D 403 (Forbidden)
Script:
Follow the script in AJAX:
$('#file').click();
$('#file').change(function(){
$.ajax({
headers: {
'X-CSRF-Token': $('input[name="_token"]').val()
},
type: 'PUT',
url: "{{ URL::to('upload/'.Auth::user()->id) }}",
data: 'file='+$('#file').val(),
enctype: 'multipart/form-data',
success: function(data){
"{{ Redirect::to('/')->with('success', 'Alterado com sucesso !') }}";
},
error: function(){
"{{ Redirect::to('/')->with('error', 'Erro no Ajax !') }}";
}
});
});
Function:
This code causes when selecting a file to upload, it triggers my controller restful - PUT.
I did the test with POST and returned the same error
– tiaguinhow
ops, files . js do not accept the Blade template. I am trying some solution and have already put here
– tiaguinhow
If you have a folder under 'public/images' for example with the same name as the view folder, it does not work.
– Leonardo