Download the PHP package ahmed-aliraqi/laravel-media-uploader without Composer
On this page you can find all versions of the php package ahmed-aliraqi/laravel-media-uploader. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ahmed-aliraqi/laravel-media-uploader
More information about ahmed-aliraqi/laravel-media-uploader
Files in ahmed-aliraqi/laravel-media-uploader
Package laravel-media-uploader
Short Description This package used to upload files using laravel-media-library
License MIT
Informations about the package laravel-media-uploader
Laravel Media Uploader
This package used to upload files using laravel-media-library before saving model.
In this package all uploaded media will be processed.
- All videos will converted to
mp4
.- All audios will converted to
mp3
.- All images
width
&height
&ratio
will be saved as custom property.- All videos & audios
duration
will be saved as custom property.Requirements
- PHP >= 7.4
- You should be ensured that the ffmpeg was installed on your server
Installation
The package will automatically register a service provider.
You need to publish and run the migration:
Publish laravel-media-library migrations:
If you want to customize
attachments
validation rules, you should publish the config file:If you want to customize validation translations, you should publish the
lang
files:This is the default content of the config file:
Use
HasUploader
trait in your model:In your controller use
addAllMediaFromTokens()
method to assign the uploaded media to model using the generated tokens:If you do not add any arguments in
addAllMediaFromTokens()
method will add all tokens inrequest('media')
with any collection.If you want to save specific collection name add it to the second argument.
Front End Basic Usage
Or Install Component Via NPM
Now you should register the component in your
resources/js/app.js
:
Usage
Attributes
Attribute | Rule | Type | Description |
---|---|---|---|
media | optional - default: [] |
array | used to display an existing files |
unlimited | optional - default:false |
boolean | upload unlimited files - if let it false will not be multiple select |
max | optional - default:12 |
int | the maximum uploaded files - if 1 will not me multiple select |
accept | optional - default: * |
string | the accepted mime types |
form | optional - default: false |
string | the form id of the uploaded media |
notes | optional - default null |
string | the help-block that will be displayed under the files |
label | optional - default null |
string | the label of the uploader |
collection | optional - default default |
string | the media library collection that the file will store in |
tokens | optional - default: [] |
array | the recently uploaded files tokens, used to display recently uploaded files in validation case |
max-width | optional - default: 1200 |
string | The maximum width of uploaded image |
max-height | optional - default: 1200 |
string | The maximum height of uploaded image |
Using with BsForm
This uploader support laravel-bootstrap-forms you can use the
image
custom component instead of vue html tag:Note: do not forget to add Cron job in your server to remove the expired temporary media.
Note: Do not forget to store the
csrf
token in an HTMLmeta
tag:
API
- Upload Files
- endpoint: /api/uploader/media/upload
- method: POST
- body:
- files[]: multipart form data
- response:
- Display Recently Uploaded Files
- endpoint: /api/uploader/media
- method: GET
- params:
- tokens[]: temporary token
- response:
- Delete Files
- endpoint: /api/uploader/media/{id}
- method: DELETE
- response:
All versions of laravel-media-uploader with dependencies
laravel/framework Version >=5.7
spatie/laravel-medialibrary Version ^9.0|^10.0
php-ffmpeg/php-ffmpeg Version ^1.0
laraeast/laravel-bootstrap-forms Version >=5.0