> For the complete documentation index, see [llms.txt](https://docs.devolutions.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.devolutions.net/powershell-universal/apps/components/inputs/upload.md).

# Upload

Add file upload controls to PowerShell Universal apps to process uploaded files up to 2GB in size within forms and steppers.

The UDUpload component is used to upload files to Universal Apps. You can process files the user uploads. You will receive the data for the file, a file name and the type of file if it can be determined by the web browser.

This component works with [UDForm](/powershell-universal/apps/components/inputs/form.md) and [UDStepper](/powershell-universal/apps/components/navigation/stepper.md).

## Uploading a File

{% hint style="warning" %}
Upload only supports files up to 2 GB in size.
{% endhint %}

Uploads a file and shows the contents via a toast.

```powershell
New-UDUpload -OnUpload {
    Show-UDToast $Body
} -Text 'Upload'
```

The body of the `OnUpload` script block is a JSON string with the following format.

```javascript
{
  data: "base64 encoded string of data",
  name: "file name of the file uploaded",
  type: "file type as determined by the browser"
}
```

The `$EventData` is an object with the following structure.

```csharp
public class Upload
{
    public string Name { get; set; }
    public string FileName { get; set; }
    public DateTime TimeStamp { get; set; }
    public string ContentType { get; set; }
    public string Type => ContentType;
}
```

## Uploading a File with a Form

Uploads a file as part of a UDForm.

```powershell
New-UDForm -Content {
    New-UDUpload -Id 'myFile' -Text 'Upload File'
} -OnSubmit {
    Show-UDToast $Body 
}
```

The body of the `OnSubmit` script block is the same one you will see with any form and the file will be contains as one of the fields within the form.

## Example: Uploading a file and save to it the temp directory

This example allows a user to upload a file. Once the file is uploaded, it will be saved to the temporary directory.

```powershell
New-UDUpload -Text 'Upload Image' -OnUpload {
    $Data = $Body | ConvertFrom-Json 
    $bytes = [System.Convert]::FromBase64String($Data.Data)
    [System.IO.File]::WriteAllBytes("$env:temp\$($Data.Name)", $bytes)
}
```

## API

[**New-UDUpload**](/powershell-universal/powershell-commands/new-udupload.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.devolutions.net/powershell-universal/apps/components/inputs/upload.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
