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

# Téléversement

Le composant UDUpload est utilisé pour téléverser des fichiers dans les applications Universal. Vous pouvez traiter les fichiers téléversés par l'utilisateur. Vous recevrez les données du fichier, un nom de fichier et le type de fichier si celui-ci peut être déterminé par le navigateur web.

Ce composant fonctionne avec [UDForm](/powershell-universal/fr/apps/components/inputs/form.md) et [UDStepper](/powershell-universal/fr/apps/components/navigation/stepper.md).

## Téléversement d'un fichier

{% hint style="warning" %}
Upload ne prend en charge que les fichiers d'une taille maximale de 2 Go.
{% endhint %}

Téléverse un fichier et affiche le contenu via un toast.

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

Le corps du bloc de script `OnUpload` est une chaîne JSON au format suivant.

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

`$EventData` est un objet ayant la structure suivante.

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

## Téléversement d'un fichier avec un formulaire

Téléverse un fichier dans le cadre d'un UDForm.

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

Le corps du bloc de script `OnSubmit` est le même que celui que vous verrez avec n'importe quel formulaire, et le fichier sera inclus en tant que l'un des champs du formulaire.

## Exemple : téléverser un fichier et l'enregistrer dans le répertoire temporaire

Cet exemple permet à un utilisateur de téléverser un fichier. Une fois le fichier téléversé, il sera enregistré dans le répertoire temporaire.

```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://github.com/Devolutions/doc-gitbook/blob/master/translations/fr/powershell-universal/cmdlets/New-UDUpload.txt)


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

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

The question should be specific, self-contained, and written in natural language.
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.
