javascript - Append data to formData object -
i seem not additionally data added "formdata".
first add input file:
var form = $('#uploadform')[0]; var formdata = new formdata(form); var input = $("#uploadphoto")[0]; //add input file data formdata formdata.append(input.name, input.files[0]);
this works fine.
, php var_dump
after "ajax call" results:
array(1) { ["uploadphoto"]=> array(5) { ["name"]=> string(5) "1.xls" ["type"]=> string(24) "application/vnd.ms-excel" ["tmp_name"]=> string(40) "..../tmp/phpmyn3e1" ["error"]=> int(0) ["size"]=> int(42799) } }
now i'd add data passing on php script:
formdata.append('usr', selectedusr); formdata.append(input.name, selectedusr); formdata.append('usr', 'usr: '+ selectedusr);
when check php var_dump, there no "usr" data in array.
why?
i think checking $_files
, check post data print_r($_post)
Comments
Post a Comment