The x-media-library-attachment will take care of the upload. Under the hood the upload is processed by
a Livewire component.
After a file has been uploaded it will be stored as a temporary upload. In case there are validation errors when
submitting the form, the x-media-library-attachment will display the temporary upload when you get redirected back to
the form. There's no need for the user to upload the file again.
In the controller handling the form submission you should validate the temporary upload and transfer it to an Eloquent
model. You can read more on that on this page.
The upload can be validated before the form is submitted by adding a rules attribute. In the value of the attribute
you can use any of Laravel's available validation rules that are applicable to file uploads.
Here's an example where we only accept png and jpg files that are 1MB or less.
This component will display the contents of the entire collection. Files can be added, removed, updated and reordered.
New files will be uploaded as temporary uploads.
The value you pass in name of the component will be use as the key name in which the component will send the state of
the collection to the backend. In the controller handling the form submission you should validate the new contents of
the collection and sync it with the collection of the eloquent model. You can read more on that on this page.
Like the x-media-library-attachment component, the x-media-library-collection accepts max-items and rules props.
In this example, the collection will be allowed to hold png and jpg files that are smaller than 1 MB.
Media library supports custom properties to be saved on a media item. By
default, the x-media-library-collection component doesn't show the custom properties. To add them you should create a
blade view that will be used to display all form elements on a row in the component.
In this example we're going to add a custom property form field called extra_field.
Under the hood, the attachment and collection components use Livewire to perform uploads. Currently, Livewire does not support uploading multiple files to S3. That's why only the attachment component can be used to upload files to S3.