A WordPress media library file picker. Stores the attachment ID.
Field::file(string $key): FileField->returnFormat(string $format): static| Format | Returns |
|---|---|
'id' (default) |
int — attachment ID |
'url' |
string — file URL |
'array' |
array — ['id', 'url', 'name', 'mime'] |
{ "cv": 231 }Field::file('project_brief')
->label('Project Brief (PDF)')
->returnFormat('array'),@php $file = ctrlfield_get('project_brief') @endphp
@if($file)
<a href="{{ $file['url'] }}" download>
Download {{ $file['name'] }} ({{ strtoupper(last(explode('/', $file['mime']))) }})
</a>
@endif