# Files

Source: https://laraport.app/docs/files/

> Browse a container's files in a Midnight Commander style panel, view them with syntax highlighting, edit .env with a diff, upload and download.

The **File browser** is a single panel in the style of Midnight Commander. Open it from the Files tab, or with `f` on the container list. It starts at the Laravel root, or at `/`.

*Screen: The file browser inside a container*

## The panel

- Name, size and modification time, plus permissions and owner on wide terminals.
- Names are marked as in mc: `/` directory, `~` link to a directory, `@` link, `*` executable.
- Below the list: the selected entry and the directory's totals.
- Directory sizes are measured in the background after the listing appears.

| Key | Action |
|---|---|
| `enter` | Open a directory or view a file |
| `backspace` | Up, with the cursor on the directory you left |
| `F3` or `v` | View |
| `F5` or `d` | Download as `.tar.gz` |
| `F6` or `u` | Upload a local file or directory here |
| `/` | Filter by name |
| `s` / `S` | Sort by name, size or time / reverse |
| `.` | Hide dotfiles |
| `~` | Back to the app root |
| `r` | Refresh |

## Viewing

Files open with syntax highlighting and line numbers: PHP, Blade, JSON, `.env`, YAML, JavaScript, TypeScript, Vue, CSS, SQL, XML, Markdown, Dockerfile, nginx, Caddy, INI, shell, and scripts recognised by their shebang. `c` toggles colours, `n` line numbers, `f2` wrapping, `d` downloads.

Files up to 2 MB are read whole. Logs and bigger files open in the [log viewer](https://laraport.app/docs/logs/), which can follow them. Binary files are offered for download.

## Editing

`e` in the viewer edits the file.

- `ctrl+s` shows the diff and saves after you confirm.
- The file is saved only if it is still what you opened, so changes made in the meantime are never overwritten.
- The previous version is kept in `/tmp/laraport/backups` in the container.
- The file is written in place, keeping its owner and mode. Tabs (shown as `␉`) and CRLF line ends are kept.
- `esc` with unsaved changes asks for a second `esc`.

## Uploading

`F6` or `u` uploads a local file or directory into the current directory. The prompt completes paths with `tab` and shows sizes.

The data streams as a tar archive straight into the container, with progress and no temporary files. It is unpacked as root, like `docker cp`, and then handed to the owner of the target directory, so files in `storage/` end up owned by `www-data`. Overwriting an existing name asks first.

## Downloading

`F5` or `d` downloads a file or directory as `.tar.gz`, streamed to your downloads folder. **Download storage** on the Files tab does the same for the app's `storage/` and shows its size first. Nothing is written on the server, and a cancelled transfer leaves no partial file.
