Hello !
I’m trying to send a photo from my phone to a symfony server and I can’t do it.
In the data sent I see that the data is there, but during the recovery, there is nothing left! When I do it with postman it works. What did I miss?
This is my html
<input type="file" (change)="onFileChanged($event)">
This is my component
onFileChanged(event) {
const file = event.target.files[0];
console.log('File input', file);
const fd = new FormData();
fd.append('file', file);
fd.append('content', JSON.stringify({test: 'I am a test !'}));
this.produitService.saveImages(fd).subscribe((event => {
console.log('subscribe Event', event);
})
);
}
This is my service
saveImages(formData: FormData) {
const endpoint = `${this.urlApi}/upload/images/produit/7`;
return this.http.post(endpoint, formData, {
reportProgress: true, observe: 'events', headers: {'Content-Type': 'multipart/form-data'}
});
}
and this is my symfony controler
$images = $request->files->all();
dump($images);
This is the payload from request
1 post - 1 participant