# File Handling

This controller handles files or links passed to your Progressive Web App when it is launched via the Launch Queue API.\
It allows your app to receive files opened by the user through the system (for example, “Open with…” a PWA).

You application must declare the appropriate [file handlers](/1.3.x/the-manifest/file-handlers.md).

**Usage**

```twig
<div {{ stimulus_controller('@pwa/file-handling') }}>
  <p>Waiting for files to open…</p>
</div

<script type="module">
  const el = document.querySelector('[data-controller="launch-queue"]');

  el.addEventListener('pwa__file-handling:selected', (e) => {
    const { data } = e.detail;
    console.log('File received via Launch Queue:', data);

    // Example: preview in an <img>
    const img = document.createElement('img');
    img.src = data;
    document.body.appendChild(img);
  });
</script>
```

### Parameters

None

### Actions

None

### Targets

None

### Events

`selected`: The app is launched with one or more files (triggered for each file).


---

# Agent Instructions: 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://pwa.spomky-labs.com/1.3.x/symfony-ux/file-handling.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.
