This commit is contained in:
knowpia
2022-09-08 15:23:13 +08:00
commit 96a49d1bd6
26 changed files with 1597 additions and 0 deletions

34
app/controller/Upload.php Normal file
View File

@@ -0,0 +1,34 @@
<?php
namespace app\controller;
use think\facade\Db;
class Upload
{
public function image()
{
if(empty($GLOBALS['data']['userid'])){
return show("请上传TOKEN");
}
if(empty($GLOBALS['data']['file'])){
return show("请选择图片!");
}
$file = $GLOBALS['data']['file'];
$dir = env('upload_directory');
if(!is_dir($dir)){
mkdir($dir, 0777, true);
}
$ext = getExt($file['name']);
$newfilename = uniqid().rand(10000,99999).'.'.$ext;
if(move_uploaded_file($file['tmp_name'], $dir.'/'.$newfilename)){
$but = aliyun($newfilename);
if(empty($but["url"])){
return show('服务器繁忙,请联系管理员');
}
return show('上传成功',SUCCESS_CODE,['url'=>$but['url']]);
}else{
return show('服务器繁忙,请联系管理员');
}
}
}