refactor: 修改图片上传接口
This commit is contained in:
@@ -22,12 +22,14 @@ class Images
|
||||
return error($validate->getError());
|
||||
}
|
||||
|
||||
$storage = config('filesystem.disks.public.url');
|
||||
|
||||
$filemd5 = $file->md5();
|
||||
$filesha1 = $file->sha1();
|
||||
$filename = Filesystem::disk('public')->putFile('images', $file);
|
||||
|
||||
$image_manager = new ImageManager(new \Intervention\Image\Drivers\Gd\Driver());
|
||||
$image = $image_manager->read('./storage/' . $filename);
|
||||
$image = $image_manager->read('.' . $storage . '/' . $filename);
|
||||
$image->scale(200, 200);
|
||||
|
||||
$idx = strrpos($filename, '.');
|
||||
@@ -50,9 +52,9 @@ class Images
|
||||
return error('上传失败');
|
||||
}
|
||||
|
||||
return success([
|
||||
'url' => '/storage/' . $filename,
|
||||
'thumb_url' => '/storage/' . $thumb_filename,
|
||||
return success('操作成功', [
|
||||
'url' => $storage .'/' . $filename,
|
||||
'thumb_url' => $storage .'/' . $thumb_filename,
|
||||
'filemd5' => $filemd5,
|
||||
'filesha1' => $filesha1
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user