更新bug

This commit is contained in:
Your Name
2026-08-20 17:47:14 +08:00
parent 35f91ee37a
commit 5794f60c5d
67 changed files with 9257 additions and 1287 deletions
@@ -4,6 +4,7 @@ namespace app\common\service\storage\engine;
use think\Request;
use think\Exception;
use think\File;
/**
* 存储引擎抽象类
@@ -67,12 +68,22 @@ abstract class Server
{
// 设置为系统内部上传
$this->isInternal = true;
// 内部上传的是磁盘文件,不是 HTTP UploadedFile。这里统一成与
// 普通上传相同的存储契约:云存储需要 realPath,本地存储需要 File 对象。
$this->file = new File($filePath);
$realPath = $this->file->getRealPath();
if ($realPath === false || !$this->file->isReadable()) {
throw new Exception('内部上传文件不可读取');
}
// 文件信息
$this->fileInfo = [
'name' => basename($filePath),
'size' => filesize($filePath),
'tmp_name' => $filePath,
'error' => 0,
'ext' => strtolower($this->file->getExtension()),
'size' => $this->file->getSize(),
'mime' => $this->file->getMime(),
'name' => basename($filePath),
'realPath' => $realPath,
'tmp_name' => $realPath,
'error' => UPLOAD_ERR_OK,
];
// 生成保存文件名
$this->fileName = $this->buildSaveName();
@@ -118,7 +129,11 @@ abstract class Server
protected function getRealPath()
{
return $this->fileInfo['realPath'];
$realPath = $this->fileInfo['realPath'] ?? '';
if (!is_string($realPath) || $realPath === '' || !is_file($realPath)) {
throw new Exception('上传文件真实路径无效');
}
return $realPath;
}
/**