Skip to content

Uploader ​

<x-mediaflow::uploader> is a standalone drop zone for single or batch uploads, with a progress bar and a preview list. Each uploaded file adds a hidden input with its media ID, so it also works inside a form.

blade
<x-mediaflow::uploader
    name="gallery_ids"
    folder="gallery/products"
    collection="product-shots"
    accept="image/*,application/pdf"
    :multiple="true"
/>

<x-mediaflow::uploader> and <x-mediaflow-uploader> are the same component.

Options ​

OptionTypeDefaultDescription
namestringmedia_idName of the hidden input. With multiple, inputs are named name[].
acceptstringimage/*Types the file dialog offers. The server still applies the upload rules.
multipleboolfalseAllow several files at once.
animatedbooltrueAnimate progress and previews.
folderstringnullFolder ID, name or path for uploads.
collectionstringdefaultCollection stored with each upload.
visibilitystringpublicpublic or private.
upload-urlstringroute('mediaflow.upload')Custom upload endpoint.

When an uploader is on the same page as a media manager, it follows the folder the manager has open.

Receiving the IDs ​

php
$request->validate([
    'gallery_ids' => 'array',
    'gallery_ids.*' => 'integer',
]);

Events ​

After every successful upload the uploader dispatches mediaflow:uploaded with { media } on its element (bubbling) and on document:

js
document.addEventListener('mediaflow:uploaded', (e) => {
  console.log(e.detail.media.url)
})

Released under the MIT License.