|
...
|
...
|
@@ -5,6 +5,7 @@ namespace App\Http\Logic\Bside; |
|
|
|
use App\Enums\Common\Code;
|
|
|
|
use App\Exceptions\BsideGlobalException;
|
|
|
|
use App\Helper\Common;
|
|
|
|
use App\Http\Controllers\ImageLogic;
|
|
|
|
use App\Http\Logic\Logic;
|
|
|
|
use App\Models\Image as ImageModel;
|
|
|
|
use Illuminate\Http\Request;
|
|
...
|
...
|
@@ -98,30 +99,8 @@ class BaseLogic extends Logic |
|
|
|
* @method
|
|
|
|
*/
|
|
|
|
public function upload(){
|
|
|
|
$image = $this->request->file('image');
|
|
|
|
if(empty($image)){
|
|
|
|
return $this->fail('没有上传图片');
|
|
|
|
}
|
|
|
|
$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());
|
|
|
|
}
|
|
|
|
$imageModel = new ImageModel();
|
|
|
|
$data = [
|
|
|
|
'path' => $url.$filename,
|
|
|
|
'created_at' => date('Y-m-d H:i:s',time()),
|
|
|
|
'size' => $res->getSize(),
|
|
|
|
'hash' => $hash.$filename,
|
|
|
|
'type'=>$image->getClientOriginalExtension(),
|
|
|
|
];
|
|
|
|
$rs = $imageModel->add($data);
|
|
|
|
if ($rs === false) {
|
|
|
|
return $this->fail('error');
|
|
|
|
}
|
|
|
|
return $hash.$filename;
|
|
|
|
$imageLogic = new ImageLogic();
|
|
|
|
return $imageLogic->upload();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
...
|
...
|
|