the following script will show, how I run an AJAX call to send some files(Images) to the server. But if I show the values in the $_POST
in PHP
, I recieve an empty array.
upload():void {
let headers = new Headers();
let formData: FormData = new FormData();
for(let i = 0; i < this.files.length; i++){
formData.append(i.toString(), this.files[i], this.files[i].name);
}
//next line is updated
formData.append('x', "test");
var returnReponse = new Promise((resolve, reject) => {
this.http.post('save.php', formData, {
headers: headers
}).subscribe(
res => {
console.info(res);
},
error => {
console.info(error);
}
);
});
I receive the PHP
output with FirePHP
and FireBug
, so the call reach the server. Where is my mistake that the $_POST
variable still empty?