Problem:
I am trying to send a form with ajax via PUT, but it is returning the following message in the 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 .