> 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/da/apps/components/inputs/upload.md).

# Upload

Tilføj filuploadkontrolelementer til PowerShell Universal-apps for at behandle uploadede filer på op til 2GB i formularer og steppere.

Komponenten UDUpload bruges til at uploade filer til Universal Apps. De kan behandle filer, som brugeren uploader. De modtager dataene for filen, et filnavn og filtypen, hvis den kan bestemmes af webbrowseren.

Denne komponent fungerer sammen med [UDForm](/powershell-universal/da/apps/components/inputs/form.md) og [UDStepper](/powershell-universal/da/apps/components/navigation/stepper.md).

## Upload af en fil

{% hint style="warning" %}
Upload understøtter kun filer på op til 2 GB i størrelse.
{% endhint %}

Uploader en fil og viser indholdet via en toast.

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

Brødteksten i scriptblokken `OnUpload` er en JSON-streng med følgende format.

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

`$EventData` er et objekt med følgende struktur.

```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;
}
```

## Upload af en fil med en formular

Uploader en fil som en del af en UDForm.

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

Brødteksten i scriptblokken `OnSubmit` er den samme, som De vil se i enhver formular, og filen vil være indeholdt som et af felterne i formularen.

## Eksempel: upload af en fil og gem den i temp-kataloget

Dette eksempel giver en bruger mulighed for at uploade en fil. Når filen er uploadet, gemmes den i det midlertidige katalog.

```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/da/powershell-kommandoer/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/da/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.
