Uploaded file by ajax not getting data in php controller in Laravel -


i using ajax upload photo in laravel. url working fine data not receiving in function in controller.

html code

<input type="file" id="photo_input"> 

ajax / jquery code

$('#photo_input').change(function(){ var formdata = new formdata('#photo_input');     $.ajax({        type:'post',        url: home_url+'/upload-image',        data:formdata,        cache:false,        enctype: 'multipart/form-data',        contenttype: false,        processdata: false,        success:function(data){                console.log("success");                 console.log(data);             },             error: function(data){                 console.log("error");                 console.log(data);             }         });     }); 


php code in controller

public function uploadimage(){   $data = input::all();   print_r($data); } 


response function in controller

array( ); 

i haven't used <form> tag in html, want upload directly. need add <form> tag? there missing?

$("#example-form").submit(function(){  var formdata = new formdata($(this)[0]);     $.ajax({         data: formdata     }); }); 

Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -