Hi. Did you find the solution? I can't find it.
Feb 6, 2023
7
Level 11
Show uploaded file in edit form using filepond
Please I have a form that is able to upload files successfully using file pond but how do I show the uploaded file in file pond when I want to edit because I always have to reupload again?
class Edit extends Component
{
public $upload;
public function mount(Upload $upload)
{
$this->file_name = $contract->file_name;
}
public function save()
{
$validatedData = $this->validate([
'file_name' => "required|mimes:pdf|max:12288",
]);
$upload = Upload::create([
'file_name' => $this->file_name->store('public/files'),
]);
$this->contract->update($validatedData);
session()->flash('success', 'Edited successfully');
return redirect()->route('home');
}
public function render()
{
return view('livewire.edit');
}
}
<div class="col-6@md">
<label class="form-label margin-bottom-xxs" > File Upload </label>
<div wire:ignore x-data x-init="FilePond.registerPlugin(FilePondPluginFileValidateType);
FilePond.setOptions({
server: {
process: (fieldName, file, metadata, load, error, progress, abort, transfer, options) => {
@this.upload('file_name', file, load, error, progress)
},
revert: (filename, load) => {
@this.removeUpload('file_name', filename, load)
}
},
allowMultiple: true,
allowFileTypeValidation: true,
});
FilePond.create($refs.input);">
<input wire:model="file_name"
class="form-control width-100% @error('file_name') is-error @enderror" type="file" x-ref="input" id="file_name">
</div>
@error('file_name')
<x-validation-error>{{ $message }}</x-validation-error>
@enderror
</div>
<button wire:click.prevent="save" class="btn btn--primary">Save changes</button>
Please or to participate in this conversation.