auroralzdf / big-file-upload
该软件包的最新版本(V2.0)没有提供许可证信息。
大文件分块上传...
V2.0
2019-02-28 06:04 UTC
Requires
- php: >=7.0.0
This package is auto-updated.
Last update: 2024-09-21 20:46:22 UTC
README
说明
结合Webuploader
的切片上传功能实现,用于解决网站处理大文件上传缓慢或无法上传的问题。
Laravel版本
>=5.5
安装
composer require auroralzdf/big-file-upload
php artisan vendor:publish --provider='AuroraLZDF\Bigfile\BigfileServiceProvider'
配置项
执行php artisan vendor:publish --provider='AuroraLZDF\Bigfile\BigfileServiceProvider'
后,会在config
目录下生成bigfile.php
配置文件。配置项说明:
<?php return [ /* |------------------------ | 文件每次切片尺寸 |------------------------ */ 'chunk_size' => 1024 * 1024 * 2, /* |------------------------ | 允许上传文件最大尺寸 |------------------------ */ 'max_size' => 1024 * 1024 * 1024, /* |------------------------ | 文件保存路径 |------------------------ */ 'save_path' => 'upload/' . date('Y') . '/' . date('m') . '/', /* |------------------------ | 文件切片缓存路径 |------------------------ */ 'tmp_path' => storage_path('app/public/tmp'), /* |------------------------ | 允许上传文件类型 |------------------------ */ 'allow_type' => ['jpg', 'jpeg', 'gif', 'png', 'mp4', 'mp3', 'zip', 'apk', 'pdf', 'rar'], /* |------------------------ | 切片文件是否随机命名 |------------------------ */ 'rand_name' => true, /* |------------------------ | 是否删除临时文件 |------------------------ */ 'remove_tmp_file' => true, ];
访问路由
Route::middleware('web')->get('/upload/bigfile', '\AuroraLZDF\Bigfile\Controllers\BigfileController@loadView')->name('bigfile_view'); // bindings:不限制API访问次数限制,不需要 csrf_token 验证 Route::middleware('bindings')->post('/upload/bigfile', '\AuroraLZDF\Bigfile\Controllers\BigfileController@upload')->name('bigfile_upload');
...