There is an object called event.formData in the onBeforeSend event of the primeng fileupload event.formData , you can use this object to configure the request with additional information. I was able to successfully implement this functionality in the current project I'm working on.
In component.ts file:
onBeforeSend(event) { event.xhr.setRequestHeader("Authorization", `Bearer ${this.authService.getToken()}`); event.formData.append('DocumentID', 'A123'); }
In the template.html file:
<p-fileUpload name="test[]" [url]="url_test" (onBeforeSend)="onBeforeSend($event)" accept="image/*" maxFileSize="5000000" withCredentials="true">
Hope this helps!
source share