> 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/de/apps/components/inputs/upload.md). Agents can also search and read this documentation through its [MCP server](https://docs.devolutions.net/~gitbook/mcp).

# Upload

Fügen Sie Steuerelemente zum Hochladen von Dateien in PowerShell Universal Apps hinzu, um hochgeladene Dateien mit einer Größe von bis zu 2 GB in Formularen und Steppern zu verarbeiten.

Die UDUpload-Komponente wird verwendet, um Dateien in Universal Apps hochzuladen. Sie können die von Benutzern hochgeladenen Dateien verarbeiten. Sie erhalten die Daten der Datei, einen Dateinamen und den Dateityp, sofern dieser vom Webbrowser ermittelt werden kann.

Diese Komponente funktioniert mit [UDForm](https://docs.devolutions.net/powershell-universal/de/apps/components/inputs/form.md) und [UDStepper](https://docs.devolutions.net/powershell-universal/de/apps/components/navigation/stepper.md).

## Hochladen einer Datei

{% hint style="warning" %}
Der Upload unterstützt nur Dateien mit einer Größe von bis zu 2 GB.
{% endhint %}

Lädt eine Datei hoch und zeigt den Inhalt über einen Toast an.

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

Der Rumpf des `OnUpload`-Skriptblocks ist eine JSON-Zeichenfolge im folgenden Format.

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

Bei `$EventData` handelt es sich um ein Objekt mit der folgenden 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;
}
```

## Hochladen einer Datei mit einem Formular

Lädt eine Datei als Teil eines UDForm hoch.

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

Der Rumpf des `OnSubmit`-Skriptblocks ist derselbe, den Sie bei jedem Formular sehen, und die Datei ist als eines der Felder im Formular enthalten.

## Beispiel: Hochladen einer Datei und Speichern im temporären Verzeichnis

Dieses Beispiel ermöglicht es einem Benutzer, eine Datei hochzuladen. Sobald die Datei hochgeladen ist, wird sie im temporären Verzeichnis gespeichert.

```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**](https://docs.devolutions.net/powershell-universal/de/powershell-befehle/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/de/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.
