xcw 2024-12-03 15:30:34 +08:00
commit a4d7590f0d
3 changed files with 17 additions and 17 deletions

View File

@ -25,7 +25,7 @@ class Upload extends BaseController
} }
$this->validate = new VUpload(); $this->validate = new VUpload();
$this->uploadPath = Config::get('filesystem.disks.local.url'); $this->uploadPath = Config::get('filesystem.disks.local.url');
if(is_writable(app()->getRootPath() . 'wwwroot' . $this->uploadPath)){ if(is_writable(app()->getRootPath() . 'public' . $this->uploadPath)){
$this->uploadPathIsWritable = 1; $this->uploadPathIsWritable = 1;
} }
} }
@ -48,7 +48,7 @@ class Upload extends BaseController
return $this->json(1, $errorMsg); return $this->json(1, $errorMsg);
} }
} }
//文件上传(通用) //文件上传(通用)
public function file() public function file()
{ {
@ -72,7 +72,7 @@ class Upload extends BaseController
return $this->json(1, $errorMsg); return $this->json(1, $errorMsg);
} }
} }
//图片上传(通用) //图片上传(通用)
public function image() public function image()
{ {
@ -91,9 +91,9 @@ class Upload extends BaseController
$return['thumb_src'] = Image::getThumb($src, 100, 100, TImage::THUMB_SCALING); //上传返回缩略图宽度为100 $return['thumb_src'] = Image::getThumb($src, 100, 100, TImage::THUMB_SCALING); //上传返回缩略图宽度为100
} }
$return['src'] = $src; $return['src'] = $src;
if($this->isCompress){ // if($this->isCompress){
Image::resize($src); // Image::resize($src);
} // }
File::add($image, $src); //加入上传文件表 File::add($image, $src); //加入上传文件表
} catch (\Exception $e) { } catch (\Exception $e) {
return $this->json(1, $e->getMessage()); return $this->json(1, $e->getMessage());
@ -108,7 +108,7 @@ class Upload extends BaseController
//富文本编辑器商城图片 //富文本编辑器商城图片
public function wangImage() public function wangImage()
{ {
$imageArr = request()->file('wang_img'); // 该方式前端js上传方法中字段名称必须以数组形式传参 如 wang_img[] = 值 $imageArr = request()->file('wang_img'); // 该方式前端js上传方法中字段名称必须以数组形式传参 如 wang_img[] = 值
$errno = 0; $errno = 0;
$data = []; $data = [];
@ -133,7 +133,7 @@ class Upload extends BaseController
} }
} }
} }
$return['errno'] = $errno; $return['errno'] = $errno;
$return['data'] = $data; $return['data'] = $data;
return json($return); return json($return);

View File

@ -14,7 +14,7 @@ class Image extends File
public static function resize($src) public static function resize($src)
{ {
$max = 1920; $max = 1920;
$realPath = app()->getRootPath() . 'wwwroot/' . ltrim($src,'/'); $realPath = app()->getRootPath() . 'public/' . ltrim($src,'/');
if(is_file($realPath)){ if(is_file($realPath)){
$img = TImage::open($realPath); $img = TImage::open($realPath);
list($img_w,$img_h) = $img->size(); list($img_w,$img_h) = $img->size();
@ -34,7 +34,7 @@ class Image extends File
$rootPath = app()->getRootPath(); $rootPath = app()->getRootPath();
if(!empty($src)){ if(!empty($src)){
$system = System::getSystem(); $system = System::getSystem();
$realPath = $rootPath . 'wwwroot/' . ltrim($src, '/'); $realPath = $rootPath . 'public/' . ltrim($src, '/');
if(is_file($realPath)){ if(is_file($realPath)){
if($system['is_mark']){ if($system['is_mark']){
$mark = $rootPath . ltrim($system['mark_img'], '/'); $mark = $rootPath . ltrim($system['mark_img'], '/');
@ -48,7 +48,7 @@ class Image extends File
} }
} }
} }
//获取水印位置键值对 //获取水印位置键值对
public static function getMarkPosition() public static function getMarkPosition()
{ {
@ -73,7 +73,7 @@ class Image extends File
public static function delImg($src) public static function delImg($src)
{ {
if(!empty(trim($src))){ if(!empty(trim($src))){
$realPath = app()->getRootPath() . 'wwwroot/' . ltrim($src, '/'); $realPath = app()->getRootPath() . 'public/' . ltrim($src, '/');
if (file_exists($realPath)) { if (file_exists($realPath)) {
$info = pathinfo($realPath); $info = pathinfo($realPath);
$source = $info['dirname'] . DIRECTORY_SEPARATOR . $info['filename'] . '*.' . $info['extension']; $source = $info['dirname'] . DIRECTORY_SEPARATOR . $info['filename'] . '*.' . $info['extension'];
@ -100,7 +100,7 @@ class Image extends File
return ''; return '';
} }
$rootPath = app()->getRootPath(); $rootPath = app()->getRootPath();
$realPath = $rootPath . 'wwwroot/' . ltrim($src, '/'); $realPath = $rootPath . 'public/' . ltrim($src, '/');
$realPath = str_replace('\\', '/', $realPath); $realPath = str_replace('\\', '/', $realPath);
if(!file_exists($realPath)){ if(!file_exists($realPath)){
return ''; return '';
@ -120,7 +120,7 @@ class Image extends File
return $src; return $src;
} }
$thumbName = $info['dirname']. DIRECTORY_SEPARATOR .$info['filename'].'_'.$width.'_'.$height.'.'.$info['extension']; $thumbName = $info['dirname']. DIRECTORY_SEPARATOR .$info['filename'].'_'.$width.'_'.$height.'.'.$info['extension'];
$realThumbName = $rootPath . 'wwwroot/' . ltrim($thumbName, '/'); $realThumbName = $rootPath . 'public/' . ltrim($thumbName, '/');
$realThumbName = str_replace('\\', '/', $realThumbName); $realThumbName = str_replace('\\', '/', $realThumbName);
if(!file_exists($realThumbName)){ if(!file_exists($realThumbName)){
$image = TImage::open($realPath); $image = TImage::open($realPath);

View File

@ -11,7 +11,7 @@ return [
// 磁盘类型 // 磁盘类型
'type' => 'local', 'type' => 'local',
// 磁盘路径 // 磁盘路径
'root' => app()->getRootPath() . 'wwwroot/storage', 'root' => app()->getRootPath() . 'public/storage',
// 磁盘路径对应的外部URL路径 // 磁盘路径对应的外部URL路径
'url' => '/storage', 'url' => '/storage',
// 可见性 // 可见性
@ -21,7 +21,7 @@ return [
// 磁盘类型 // 磁盘类型
'type' => 'local', 'type' => 'local',
// 磁盘路径 // 磁盘路径
'root' => app()->getRootPath() . 'wwwroot/storage/videos', 'root' => app()->getRootPath() . 'public/storage/videos',
// 磁盘路径对应的外部URL路径 // 磁盘路径对应的外部URL路径
'url' => '/storage/videos', 'url' => '/storage/videos',
// 可见性 // 可见性
@ -31,7 +31,7 @@ return [
// 磁盘类型 // 磁盘类型
'type' => 'local', 'type' => 'local',
// 磁盘路径 // 磁盘路径
'root' => app()->getRootPath() . 'wwwroot/storage/backup', 'root' => app()->getRootPath() . 'public/storage/backup',
// 磁盘路径对应的外部URL路径 // 磁盘路径对应的外部URL路径
'url' => '/storage/backup', 'url' => '/storage/backup',
// 可见性 // 可见性