Monday, April 10, 2017

$_POSt returns unexpected array

print_r($_POST) returns

Array ( [-----------------------------80612539230530 Content-Disposition:_form-data;_name] => "attach_doc" undefined -----------------------------80612539230530 Content-Disposition: form-data; name="_token" M2gNgjdyAItV3aYLXRgz7DkR5uPDN16esKfeFtKL -----------------------------80612539230530 Content-Disposition: form-data; name="_token" M2gNgjdyAItV3aYLXRgz7DkR5uPDN16esKfeFtKL -----------------------------80612539230530 Content-Disposition: form-data; name="cl_shipment_id" 30 -----------------------------80612539230530 )

and not the formatted array.

Having the ajax post call as

var form_data= new FormData();

form_data.append('attach_doc',file);

form_data.append('_token', $("input[name=_token]").val());

var other_data = $("#store_shipment_frm").serializeArray();

$.each(other_data,function(key,input){

form_data.append(input.name,input.value);

});

$.ajax({ cache: false, dataType: 'text', contentType: false, processData: false, url: common_ajax_url+"-----", type: "post", data:form_data,

I am using this in Laravel, What wrong:(



via fernandus

Advertisement