# UploadHandlerFile

> A specialized UploadHandler that reads data from a given file and sends raw bytes to the server as the request body.

## Definition

* **Type:** Class
* **Namespace:** [UnityEngine.Networking](/engine/6000.7/script-reference/unityengine/networking.md)
* **Assembly:** UnityEngine.UnityWebRequestModule
* **Inherits from:** [UploadHandler](/engine/6000.7/script-reference/unityengine/networking/uploadhandler.md)
* **Implements:** [IDisposable](https://learn.microsoft.com/dotnet/api/system.idisposable)

```csharp
public sealed class UploadHandlerFile : UploadHandler, IDisposable
```

## Remarks

You can use it to send a large amount of data to the server with a low memory footprint.

## Examples

```csharp
using System.Collections;
using UnityEngine;
using UnityEngine.Networking;

public class UHFileSample : MonoBehaviour
{
    void Start()
    {
        StartCoroutine(UploadFileData());
    }

    IEnumerator UploadFileData()
    {
        using (var uwr = new UnityWebRequest("https://yourwebsite.com/upload", UnityWebRequest.kHttpVerbPUT))
        {
            uwr.uploadHandler = new UploadHandlerFile("/path/to/file");
            yield return uwr.SendWebRequest();
            if (uwr.result != UnityWebRequest.Result.Success)
                Debug.LogError(uwr.error);
            else
            {
                // file data successfully sent
            }
        }
    }
}
```

## Constructors

| Constructor                                                                                                          | Description                                                                 |
| -------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------- |
| [UploadHandlerFile(System.String)](/engine/6000.7/script-reference/unityengine/networking/uploadhandlerfile/ctor.md) | Create a new upload handler to send data from the given file to the server. |

## Inheritance

**Inherited Members:**

* [UploadHandler.Dispose()](/engine/6000.7/script-reference/unityengine/networking/uploadhandler/dispose.md)
* [UploadHandler.data](/engine/6000.7/script-reference/unityengine/networking/uploadhandler/data.md)
* [UploadHandler.contentType](/engine/6000.7/script-reference/unityengine/networking/uploadhandler/contenttype.md)
* [UploadHandler.progress](/engine/6000.7/script-reference/unityengine/networking/uploadhandler/progress.md)
