This commit is contained in:
2025-07-08 10:54:46 +08:00
8 changed files with 29 additions and 4 deletions

View File

@@ -72,7 +72,7 @@ class Upload
$webp = $image->toWebp(75);
$root = config('filesystem.disks.image.root');
$filename = $param['module'] . '/' . ($name_rule() ?? date('Ymd') . '/' . md5((string)time()) . '.webp');
$webp->save($root . '/' . $filename);
$webp->save($this->checkPath($root . '/' . $filename));
// 获取webp文件大小
$file_size = $webp->size();
// 获取webp文件mime类型
@@ -171,11 +171,36 @@ class Upload
'filesha1' => $image_model->file_sha1
]);
} catch (\Throwable $th) {
dump($th);exit;
return error($th->getMessage());
}
return error('上传失败');
}
/**
* 检查路径
*
* @param string $path
* @return string
*/
private function checkPath($path): string
{
$ok = false;
$filename = basename($path);
$dirname = dirname($path);
if (!is_dir($dirname)) {
$ok = @mkdir($dirname, 0755, true);
}
else if (!is_writable($dirname)) {
$ok = @chmod($dirname,0755);
}
if ($ok) {
return $dirname . '/' . $filename;
}
throw new \Exception("上传目标目录不可用");
}
/**
* 文件名生成回调
*

View File

@@ -6,7 +6,7 @@
<div class="orico_Page_brand">
<!--内容 -->
<div class="brandMain">
<img src="__IMAGES__/OurBrand.png" class="img-responsive" />
<img src="__IMAGES__/OurBrand.webp" class="img-responsive" />
{notempty name="banners"}
<div class="our_brand_con">
{volist name="banners" id="ba" offset="0" length="2"}

View File

@@ -7,7 +7,7 @@
<!-- 内容 -->
<div class="downloadMain">
<div class="topimg">
<img src="__IMAGES__/banner_01.png" />
<img src="__IMAGES__/banner_01.webp" />
<div class="banner_title">{:lang_i18n('软件和驱动程序')}</div>
</div>
<div class="contact_c">

View File

@@ -7,7 +7,7 @@
<!-- 内容 -->
<div class="downloadMain">
<div class="topimg">
<img src="__IMAGES__/banner_01.png" />
<img src="__IMAGES__/banner_01.webp" />
<div class="banner_title">{:lang_i18n('软件和驱动程序')}</div>
</div>
<div class="contact_c">

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 185 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB