重构默认本地上传组件;

This commit is contained in:
2022-08-22 11:51:19 +08:00
parent b0ffb84fd6
commit e0d00e4422
5 changed files with 90 additions and 24 deletions

View File

@@ -0,0 +1,30 @@
<?php
namespace think\filesystem\driver;
use think\facade\Request;
class LocalPublic extends Local
{
public function url(string $path): string
{
$url = sysconfig('upload', 'local_domain');
if (empty($url)) {
$host = Request::host();
if (!empty($host)) {
$url = Request::domain();
}
}
if (isset($this->config['url'])) {
$url = trim($url, '/') . '/' . trim($this->config['url'], '/');
}
if (isset($url)) {
return $this->concatPathToUrl($url, $path);
}
return parent::url($path);
}
}