2017 © Pedro Peláez
 

library upload-file

upload file for PHP laravel

image

wubuze/upload-file

upload file for PHP laravel

  • Wednesday, August 1, 2018
  • by wubuze
  • Repository
  • 0 Watchers
  • 1 Stars
  • 2 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Laravel 上传文件

安装

  • composer require wubuze/upload-file, (*1)

  • app\config\app.php 文件中provider 加上, laravel5.5 以上可以忽略, (*2)

  • Wubuze\UploadFile\UfffServiceProvider::class,, (*3)

  • php artisan vendor:publish , 选择 wubuze-file-config, (*4)

  • 生成的storage.php 文件里面可以配置文件上传路径, (*5)

  • php artisan storage:link, (*6)

迁移数据库,创建model

  • php artisan migrate 生成表 file、file_group, (*7)

  • 创建 App\Model\File 必须继承 UploadFile\Model\File\File, (*8)

  • 创建 App\Model\FileGroup 继承 UploadFile\Model\File\FileGroup

上传文件

  • use UploadFile\File\Uploader;
  • $module = config('storage.'.$req->input('module')); if (!$module) { return 'error'; }, (*9)

  • Uploader::init($req->file('file'));, (*10)

  • $file = Uploader::upload($module['dir'], $req->input('fileName'), $module['public']);
  • $file->setUrl();, (*11)

  • return @[ 'id' => $file->id, 'url' => $file->url, 'top' => $file->top, 'name' => $file->file.'.'.$file->type, ];, (*12)

The Versions

01/08 2018

dev-master

9999999-dev

upload file for PHP laravel

  Sources   Download

MIT

The Requires

 

upload file upload img