|
|
@@ -84,45 +84,11 @@ class UploadController extends BaseController
|
|
|
util::fail('上传失败!!');
|
|
|
}
|
|
|
$img = "uploads/{$sjId}/{$month}/{$date}/" . $newFile;
|
|
|
- $imgInfo = getimagesize($fullPathFile);
|
|
|
- $width = $imgInfo[0];
|
|
|
- $height = $imgInfo[1];
|
|
|
-
|
|
|
- //如果图片太大,进行压缩,并删除原图
|
|
|
- if ($width > 800) {
|
|
|
- $newWidth = 800;
|
|
|
- $newHeight = ceil((800 * $height) / $width);
|
|
|
- $preFileName = stringUtil::uniqueFileName();
|
|
|
- $newFile = $preFileName . ".{$type}";
|
|
|
- $newFullPathFile = $path . $newFile;
|
|
|
- Image::thumbnail($fullPathFile, $newWidth, $newHeight)->save($newFullPathFile, ['quality' => 100]);
|
|
|
- $width = $newWidth;
|
|
|
- $height = $newHeight;
|
|
|
- $img = "uploads/{$sjId}/{$month}/{$date}/" . $newFile;
|
|
|
- unlink($fullPathFile);
|
|
|
- $fullPathFile = $newFullPathFile;
|
|
|
- }
|
|
|
|
|
|
oss::uploadImage($img, $fullPathFile);
|
|
|
- //生成小图 200px
|
|
|
- //$smallWidth = 200;
|
|
|
- //$smallHeight = ceil((200 * $height) / $width);
|
|
|
- //$smallFullPathFile = $path . $preFileName . '_small.' . $type;
|
|
|
- //Image::thumbnail($fullPathFile, $smallWidth, $smallHeight)->save($smallFullPathFile, ['quality' => 100]);
|
|
|
|
|
|
$data = business::formatUploadImg($img);
|
|
|
|
|
|
-// if (!empty($categoryIds)) {
|
|
|
-// $time = time();
|
|
|
-// $data = ['img' => $img, 'sjId' => $sjId, 'name' => '未命名', 'addTime' => $time];
|
|
|
-// $pic = PicService::add($data);
|
|
|
-// $currentId = $pic['id'];
|
|
|
-// $add = [];
|
|
|
-// foreach ($categoryIds as $cat) {
|
|
|
-// $add[] = ['categoryId' => $cat, 'picId' => $currentId, 'sjId' => $this->sjId];
|
|
|
-// }
|
|
|
-// PicCategoryService::batchAdd($add);
|
|
|
-// }
|
|
|
$data['shortUrl'] = $img;
|
|
|
$data['smallShortUrl'] = $img . "?x-oss-process=image/resize,l_200";
|
|
|
util::success($data);
|