Search 71 components and 72 controllers by name, category or description.
File
Native file input with validation, current-file links, failed Turbo submit restore and optional reset
Props
A bare <input type="file"> by default — the controllers mount on the input itself, never on a wrapper. The wrapper appears only for current-url or wrapper-class.
{{-- Bare input: the file-preserve controller mounts directly on it, no wrapper. --}}
<hw:field name="attachment" label="Single file">
<hw:file accept=".pdf,.txt" />
</hw:field>
{{-- multiple appends [] to the name so PHP receives an array. --}}
<hw:field name="documents" label="Multiple files">
<hw:file multiple accept=".pdf,.txt" />
</hw:field>
{{-- current-url is one of the two things that make the wrapper render. --}}
<hw:field name="avatar" label="Existing file">
<hw:file current-url="https://laravel.com/img/logomark.min.svg" />
</hw:field>
<hw:field name="contract" label="Existing file, custom label">
<hw:file
current-url="https://laravel.com/img/logomark.min.svg"
current-label="Signed contract (PDF)"
/>
</hw:field>
No old() repopulation
Browsers refuse to pre-fill a file input, so unlike hw:input this component skips the old() merge and a value attribute does nothing. Errors still resolve through the field's error key, and reset-on-success clears the input after a successful turbo:morph.
{{-- Browsers refuse to pre-fill a file input, so this component deliberately skips
the old() merge that hw:input does. A value attribute is inert here. --}}
<hw:field name="proof" label="Proof of address">
<hw:file />
</hw:field>
{{-- Validation errors still resolve normally through the field's error key. --}}
<hw:field name="rejected_upload" label="What a rejected upload looks like" :error="false">
<hw:file aria-invalid="true" />
<hw:field.error messages="The file must be a PDF smaller than 2 MB." />
</hw:field>
{{-- reset-on-success clears the input after a successful turbo:morph, which matters
when the form stays on screen inside a frame. --}}
<hw:field name="report" label="Cleared after a successful morph">
<hw:file reset-on-success />
</hw:field>
Native file preservation in a Turbo Frame
Submit with an empty caption to re-render the frame with validation errors. The native FileList survives; a valid submission clears it without persisting the file.
Unrelated sibling frame
This node is not replaced when the proof form responds.
<div class="grid gap-4 lg:grid-cols-[minmax(0,1fr)_18rem]">
<hw:frame id="native-file-proof">
<div class="grid gap-5 rounded-xl border bg-card p-5">
@if ($nativeFileDemoSuccess)
<div class="rounded-lg border border-primary/30 bg-primary/5 px-4 py-3 text-sm" role="status" data-file-proof-success>
{{ $nativeFileDemoSuccess }}
</div>
@endif
<hw:form
:action="route('components.file.preservation')"
method="post"
enctype="multipart/form-data"
track-frame-src
novalidate
class="grid gap-5"
>
<hw:field
name="proof_file"
:error="false"
required
>
<hw:field.label for="proof_file" required>Small proof file</hw:field.label>
<hw:file name="proof_file" id="proof_file" error-key="proof_file" required />
<hw:field.description>Up to 64 KB. It is validated in memory and never stored.</hw:field.description>
<hw:field.error name="proof_file" id="proof_file-error" />
</hw:field>
<hw:field
name="caption"
:error="false"
required
>
<hw:field.label for="caption" required>Caption</hw:field.label>
<hw:input
name="caption"
id="caption"
error-key="caption"
:value="old('caption')"
maxlength="80"
required
/>
<hw:field.description>Leave this empty once to exercise server validation.</hw:field.description>
<hw:field.error name="caption" id="caption-error" />
</hw:field>
<div>
<hw:button type="submit">Validate without storing</hw:button>
</div>
</hw:form>
</div>
</hw:frame>
<hw:frame id="native-file-sibling">
<div class="rounded-xl border border-dashed bg-muted/30 p-5" data-file-proof-sibling>
<p class="text-sm font-medium">Unrelated sibling frame</p>
<p class="mt-2 text-sm text-muted-foreground">
This node is not replaced when the proof form responds.
</p>
</div>
</hw:frame>
</div>