Browse Source

文件上传处理保存图片优化

master
wanghongjun 5 months ago
parent
commit
ee9d915c04
  1. 11
      app/common/controller/Upload.php

11
app/common/controller/Upload.php

@ -100,7 +100,7 @@ class Upload extends BaseController
$object='/'.ltrim($object,'/');
// 压缩图片
$compress_img = $file['compress_img'] ?? '';
if ($filecate == 'image' && empty($compress_img) && $message) {
if ($filecate == 'image') {
$compress_img = $this->getCompressImg($object, $info['ext'], $prefix);
}
$ret = [
@ -433,9 +433,18 @@ class Upload extends BaseController
{
$newName2 = uniqid() . '.' . $ext;
$compress_path = $prefix . $newName2;
$fullPath = root_path().'public/';
if($this->disk=='local'){
$compress_path='/storage/'.$compress_path;
$fullPath .= 'storage/';
}
// 提前创建目录
$fullPath .= $prefix;
if (!is_dir($fullPath)) {
mkdir($fullPath, 0755, true);
}
// 原图地址
$filePath = root_path().'public' . $src;
// 处理图地址

Loading…
Cancel
Save