|
...
|
...
|
@@ -100,25 +100,25 @@ class BaseLogic extends Logic |
|
|
|
if(empty($image)){
|
|
|
|
return $this->fail('没有上传图片',Code::USER_ERROR);
|
|
|
|
}
|
|
|
|
$hash = hash_file('md5', $image->getPathname());
|
|
|
|
$url = './../uploads/images/';
|
|
|
|
$filename = date('ymdHis').rand(10000,99999);
|
|
|
|
$res = $this->request->file('image')->move($url,$filename);
|
|
|
|
if ($res === false) {
|
|
|
|
return $this->fail($image->getError(), Code::USER_ERROR);
|
|
|
|
}
|
|
|
|
$imageModel = new ImageModel();
|
|
|
|
$data = [
|
|
|
|
'path' => $url.$filename,
|
|
|
|
'created_at' => date('Y-m-d H:i:s',time()),
|
|
|
|
'size' => $res->getSize(),
|
|
|
|
'hash' => hash_file('md5', $res->getPathname()),
|
|
|
|
'hash' => $hash.$filename,
|
|
|
|
'type'=>$image->getClientOriginalExtension(),
|
|
|
|
// 'mime'=>$image->getMimeType()
|
|
|
|
];
|
|
|
|
$imageModel = new ImageModel();
|
|
|
|
$rs = $imageModel->add($data);
|
|
|
|
if ($rs === false) {
|
|
|
|
return $this->fail('添加失败', Code::USER_ERROR);
|
|
|
|
}
|
|
|
|
return $data['hash'];
|
|
|
|
return $hash.$filename;
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|