私のフォームの提出には、次のものがあります。
var formData = new FormData();
for (var i = 0; i < ctx.files.length; i++) {
formData.append('file[]', ctx.files[i]);
}
私のサーバー側では、$_POST をダンプするだけです。
私は得る:
array(1) {
["file"]=>
array(1) {
[0]=>
string(17) "[object FileList]"
}
}
文字列として渡されますが、ファイルの配列として取得するにはどうすればよいですか?
リクエスト全体は次のとおりです。
var formData = new FormData();
for (var i = 0; i < ctx.files.length; i++) {
formData.append('file[]', ctx.files[i]);
//formData.push(ctx.files[i]);
}
// now post a new XHR request
var xhr = new XMLHttpRequest();
xhr.open('POST', '/site-manager-gateway/add-content');
xhr.onload = function () {
if (xhr.status === 200) {
console.log('all done: ' + xhr.status);
} else {
console.log('Something went terribly wrong...');
}
};
xhr.send(formData);