davelwang / thinkphp5_uploader
thinkphp5 upload
Installs: 12
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/davelwang/thinkphp5_uploader
Requires
- aliyuncs/oss-sdk-php: ^2.3
- qiniu/php-sdk: ^7.2
This package is auto-updated.
Last update: 2025-11-20 16:40:08 UTC
README
创建文件/application/extra/davel.php
<?php
return [
'upload' => [
'driver' => 'File',
'validate' => [
'image' => ['size'=>6048000,'ext'=>'jpg,png,gif,jpeg'],
'file' => ['size'=>6048000,'ext'=>'zip']
],
'Aliyun' => [
'id' => '',
'key' => '',
'endpoint' => '',
'bucket' => '',
'host' => '', //外网地址
],
'Qiniu' => [
'ak' => '',
'sk' => '',
'bucket' => '',
'host' => '', //外网地址
],
'File' => [
],
],
];
使用
$file = $this->request->file('file');
if($file==null) return false;
$uploader = new \davel\thinkphp5\Uploader();
$savepath = $uploader->upload($file,'path','image');
if($savepath==false) {
$error = $uploader->getError();
return false;
}
return true;