0

In my client side , i created an excel file , i worked with exceljsworkbook. I would like to send that excel file to my backend side (symfony ). my code :

 sendExcel(fileObj : File) {
 let headers = new HttpHeaders({'Content-Type' : 'multipart/form-data'});
 let options = { headers: headers };
 let formData = new FormData();
 formData.append('file', fileObj);
 return this.httpClient.post('api/ExcelToPdf/',formData,options).pipe(
   map(res => res ));
 }

 this.myservice.sendExcel(this.workbook).subscribe((res) => { 
 console.log(res)});

In my backend server i test for the existance of the file. in my case , i don't get any . but with POSTMAN everything is alright !

POSTMAN Test image

Then i visualise that the problem is in the notebook instance.

   this.workbook = new Workbook();

it is not considered as a file. it there a way to cast it as a file ? i worked with exceljs.

backend code:

 public function exceltopdfAction(Request $request){
    $file = $request->files->get('file');
    dump(count($_FILES));
    return new JsonResponse(count($_FILES));
}
patron
  • 59
  • 3
  • 10

0 Answers0