For quite a while I'm failing to upload images through Ajax. I get a 500 internal error which I think relates to the fact that Ajax doesn't recognize that It's an image. I'm using this syntax which works well for comments, and likes. Images is where I have the problem. I'm not showing the controller since the request doesn't even get there.
$(document).ready(function(){
 $(document).delegate(".send-image","click",function(e){ 
  e.preventDefault();
  var idval = this.id;
  var file =  $('input[type=file]').val().split('\\').pop();
  console.log(file);
    $.ajax({
      url: 'store',
      type: "post",
        beforeSend: function (xhr) {
        var token = $('meta[name="csrf_token"]').attr('content');
        if (token) {
              return xhr.setRequestHeader('X-CSRF-TOKEN', token);
        }                
    }, 
    data: {'id': idval, 'filename': file},
    success:function(data){
      console.log(data);   
    },error:function(){ 
        console.log("error!!!!");
    } 
  });      
 });  
});
