FileUpload
Livewire native file upload
Last updated
Was this helpful?
Livewire native file upload
Last updated
Was this helpful?
This field requires you to configure Livewire file uploads according to the main documentation. Setup . This component handles the rest.
Read livewire docs about scheduling cleanup of the temporary storage folder
Read livewire docs about saving the files
Livewire requires you to add the property for file-upload fields, to the form component
Livewire default validation rules are in its config file. This is fine until you want to use custom validation. The problem is that the file gets uploaded before your custom validation executes, and the file remains on the server. The FileUpload field has a workaround that deletes the temporary file if your custom validation fails. The user is presented with a general error that you define in the language files. This component tries to minimize unwanted files in the temp folder, by forcing the user to delete uploaded files before they can upload new ones.
Not using s3: Livewire will handle the file cleanup automatically.
Using s3: You must schedule the cleanup
The data is accessed via the fields name
property, like $this->fieldname
.
The FileUpload data is never available in the form_data
property, you access it with $this->foo
because Livewire requires you to define the property on the component.
(Read Livewire docs about various ways to )
(Read more about to understand saveFoo()
)