PHP code example of de-memory / media-selector

1. Go to this page and download the library: Download de-memory/media-selector library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

de-memory / media-selector example snippets


php artisan vendor:publish --provider=Encore\MediaSelector\MediaSelectorServiceProvider

php artisan migrate --path=vendor/de-memory/media-selector/database/migrations

php artisan media-selector:install

composer update

// 强制发布静态资源文件
php artisan vendor:publish --tag=media-selector --force

// 清理视图缓存
php artisan view:clear

/**
* move:第一个参数上传路径(默认路径upload_files),第二个参数媒体名是否加密(默认false)
*
* type:上传类型,选择类型(模态框上传无限制)
*
*/
$form->mediaSelector('avatar', '头像')->move('user', true)->type('image')->help('只能上传png, jpg, jpeg, bmp, gif, webp, psd, svg, tiff');

/**
* maxFileCount:上传数量,选择数量(模态框上传无限制)
*
* sortable:开启推动排序
*
*/
$form->mediaSelector('avatar1', '头像1')->maxFileCount(3)->sortable()->help('最多上传或选择三个媒体文件,可推动排序');

php artisan migrate:rollback --path=vendor/de-memory/media-selector/database/migrations