davelwang / thinkphp5_uploader
thinkphp5 upload
dev-master
2019-06-10 08:36 UTC
Requires
- aliyuncs/oss-sdk-php: ^2.3
- qiniu/php-sdk: ^7.2
This package is auto-updated.
Last update: 2025-02-20 14:56:13 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;