получить 400 неверных запросов для метода http post (загрузить файл) в Angular 7

#angular7 #form-data

#angular7 #форма-данные

Вопрос:

У меня что-то странное, и я не могу найти причину этого, у меня есть два приложения Angular, в первом я могу правильно загрузить свой файл в серверную часть, а во втором я использую тот же код и ту же службу для загрузки файла, но я получаю ошибку 400 неверный запрос, и я не знаю, где искать ошибку?

document.html

 <div fxLayout="row" fxFlex fxFill>
<form #ajouterUnFichier=ngForm (ngSubmit)="onSubmitUnFichier(descFichier, fichier)"
    fxLayout="column" fxLayoutGap="10px" fxFlexAlign="center center" fxFlex="40%">
<mat-form-field>
  <input type="text" matInput #descFichier id="descFichier" placeholder="Entrez le nom">
</mat-form-field>

<input type="file" id="fichier" (change)="choisirFichier($event)" #fichier
       accept=".csv, .xlsx, .pdf, .doc"
/>
<div fxLayout="row" fxLayoutGap="10px">
  <button type="submit" mat-raised-button color="primary" [disabled]="!ajouterUnFichier.valid">
    Enregistrer
  </button>
  <button type="submit" mat-raised-button color="accent">
    Annuler
  </button>
</div>
  

в document.ts

 selectedFile: File = null;

choisirFichier(event) {
if (event.target.files.length > 0) {
  this.selectedFile = <File>event.target.files[0];
 }
}
onSubmitUnFichier(descriptif: any, file: any) {
this.personneDocumentS.createFile(descriptif, this.selectedFile).subscribe(
  res => {
    if (res.status === 'error') {
      console.log('Error');
    } else {
      console.log('Sucess ************* ');
    }
  }
);
}
  

в document.service

 createFile(desc: string, fichier: File) {
const fd = new FormData();
fd.append('file', fichier);
fd.append('id_personne', '1');
fd.append('nom_document', 'fileName');
fd.append('descriptif', desc);
return this.httpClient.post<any>('http://localhost/silose/documents/add', fd);
}
  

В первом приложении все идет очень хорошо, но для второго у меня есть:

 zone.js:3243 POST http://localhost/silose/documents/add 400 (Bad Request)
  

если у вас есть какие-либо идеи, где искать проблему

с уважением