Below is my ajax code to upload the file
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
$('.fileupload').on('change',function(){ var formObj = $('#myForm'); var formData = new FormData(formObj[0]); $.ajax({ url: siteUrl+'/getmydata', async: true, type: "POST", data: formData, dataType: "json", success: function (data) { alert(data.count); } }); }); |
Please add the below code to work the fileupload proper
1 2 3 4 5 6 7 |
<script type="text/javascript"> $.ajaxSetup({ headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') } }); </script> |
if the issue still exists add the following extra things in the ajax call
1 2 3 4 5 6 7 8 9 |
url: siteUrl+'/get_gstrefno_from_excel', async: true, type: "POST", data: formData, dataType: "json", contentType: false, cache: false, processData: false, |