# Credentials, Headers, and Additional Data

During file upload or removal, you can control whether or not to send cookies and headers for cross-site requests, attach custom headers, or send additional data.

## Attaching Credentials to Requests

To send credentials with cross-origin upload and remove requests, set the [`withCredentials`](https://www.telerik.com/kendo-angular-ui-develop/components/uploads/api/uploadcomponent#withcredentials) option to `true`. By default, cross-origin requests are sent without credentials. Same-origin requests include browser-managed credentials, such as cookies, by default; `withCredentials` does not affect them.

[Demo Source](https://demos.telerik.com/kendo-angular-ui/demos/uploads/upload/credentials/source.txt)

## Attaching Additional Data to Requests

You can also send additional data in the form of key/value pairs.

Depending on when the data will be sent:

* In the `upload` event handler, set the [data](https://www.telerik.com/kendo-angular-ui-develop/components/uploads/api/uploadevent#data) property of the [UploadEvent](https://www.telerik.com/kendo-angular-ui-develop/components/uploads/api/uploadevent) argument, or
* In the `remove` event handler, set the [RemoveEvent](https://www.telerik.com/kendo-angular-ui-develop/components/uploads/api/removeevent) argument.

[Demo Source](https://demos.telerik.com/kendo-angular-ui/demos/uploads/upload/credentials/additional-data/source.txt)

## Configuring Request Headers

The Upload component sends files as [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData) through Angular's `HttpClient`. As a result, the browser automatically sets the `Content-Type` header to `multipart/form-data` and appends the required boundary string. The Upload does not set a `Content-Type` header explicitly because this prevents the browser from generating the correct boundary and causes the server to reject the request.

### Setting Static Headers

To attach custom headers to every upload request, use the [`saveHeaders`](https://www.telerik.com/kendo-angular-ui-develop/components/uploads/api/uploadcomponent#saveHeaders) input property. For remove requests, use the [`removeHeaders`](https://www.telerik.com/kendo-angular-ui-develop/components/uploads/api/uploadcomponent#removeHeaders) input property. Both properties accept an Angular [`HttpHeaders`](https://angular.dev/api/common/http/HttpHeaders) instance.

The following example demonstrates how to configure static headers through the `saveHeaders` property. The configured headers appear above the component.

[Demo Source](https://demos.telerik.com/kendo-angular-ui/demos/uploads/upload/credentials/static-headers/source.txt)

### Setting Dynamic Headers

To add or modify headers on a per-request basis, use the `headers` property of the [`UploadEvent`](https://www.telerik.com/kendo-angular-ui-develop/components/uploads/api/uploadevent) or [`RemoveEvent`](https://www.telerik.com/kendo-angular-ui-develop/components/uploads/api/removeevent) argument in the corresponding event handler. Because `HttpHeaders` is immutable, call the `append` method and reassign the result.

The following example demonstrates how to set dynamic headers in the `upload` event handler. The headers change with each upload request, as shown in the panel above the component.

[Demo Source](https://demos.telerik.com/kendo-angular-ui/demos/uploads/upload/credentials/custom-headers/source.txt)

## Suggested Links

* [API Reference of the Upload](https://www.telerik.com/kendo-angular-ui-develop/components/uploads/api/uploadcomponent)
