PHP code example of fengwuyan / file-selector

1. Go to this page and download the library: Download fengwuyan/file-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/ */

    

fengwuyan / file-selector example snippets


php artisan vendor:publish --provider=Encore\FileSelector\FileSelectorServiceProvider

php artisan migrate --path=vendor/fengwuyan/file-selector/database/migrations

php artisan file-selector:install


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

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

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

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

/**
* setModule方法限定模块名
*
* 可选资源列表只会显示default(公共)和对应模块的资源
* 上传文件会默认归属到指定模块,其他模块不可见
*
*/
$form->fileSelector('avatar2', '头像2')->setModule('模块名');