夺
This commit is contained in:
34
app/controller/Upload.php
Normal file
34
app/controller/Upload.php
Normal 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('服务器繁忙,请联系管理员');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user