在生产环境中调用资产不起作用 拉拉维尔 8(共享主机)



你好,我在生产环境中调用我的资产时遇到了问题,这就是文件夹的结构

  • Laravel/
    • 存储

  • public_html/
    • 存储(我创建并使用的符号链接,ln-sfn(domains/sites.com/new/storage/app/public/posted-images//public_html/(

这就是我对资产的称呼:

<img src="{{ asset('storage/'.$posts->image)  }}" alt="" class="img-fluid">

这就是我的filesystem.php的样子:

'disks' => [
'local' => [
'driver' => 'local',
'root' => storage_path('app'),
],
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
],
'links' => [
public_path('storage') => storage_path('app/public'),
],

在.env中我输入:

FILESYSTEM_DRIVER = public

所以我找到了这样的解决方案:首先,我要删除我使用ln-sfn domains/sites.com/new/storage/app/public/posted-images/创建的存储链接/public_html/

然后,在filesystem.php中更改:

'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
],

'public' => [
'driver' => 'local',
'root' => 'storage',
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
],

之后,向store函数发出请求,它将在publichtml中创建存储文件夹。你的旧文件可能不会出现在那里,所以(在你将root更改为"storage"之前的文件(,你可以从域中的storage文件夹中复制不在那里的数据。

我称资产的方式与上面相同。

最新更新