1、文件上传验证
2、增加图片上传配置 2、接口功能优化
This commit is contained in:
@@ -46,7 +46,7 @@ class Api {
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
protected function checkAuthor($header){return true;
|
||||
protected function checkAuthor($header){
|
||||
if (isset($header['authorization']) && $header['authorization']) {
|
||||
list($appid, $sign) = explode('{|}', $header['authorization']);
|
||||
$this->client = db('Client')->where('appid', $appid)->find();
|
||||
|
||||
@@ -19,7 +19,10 @@ class Upload {
|
||||
$config = $this->$upload_type();
|
||||
// 获取表单上传文件 例如上传了001.jpg
|
||||
$file = request()->file('file');
|
||||
$info = $file->move($config['rootPath'], true, false);
|
||||
$info = $file->validate(array(
|
||||
'size' => $config['size'],
|
||||
'ext' => $config['ext'],
|
||||
))->move($config['rootPath'], true, false);
|
||||
|
||||
if ($info) {
|
||||
$return['status'] = 1;
|
||||
@@ -155,7 +158,7 @@ class Upload {
|
||||
$data['m_time'] = $info->getMTime(); //获取最后修改时间
|
||||
$data['owner'] = $info->getOwner(); //文件拥有者
|
||||
$data['savepath'] = $info->getPath(); //不带文件名的文件路径
|
||||
$data['url'] = $data['path'] = str_replace("\\", '/', substr($info->getPathname(), 1)); //全路径
|
||||
$data['url'] = $data['path'] = '/uploads/' . $info->getSaveName(); //全路径
|
||||
$data['size'] = $info->getSize(); //文件大小,单位字节
|
||||
$data['is_file'] = $info->isFile(); //是否是文件
|
||||
$data['is_execut'] = $info->isExecutable(); //是否可执行
|
||||
|
||||
Reference in New Issue
Block a user