繁体   English   中英

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

[英]calling asset on production env didn't work Laravel 8 (shared hosting)

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

  • 拉拉维尔/
    • 贮存
    • ...
  • public_html/
    • 存储(我创建并使用的符号链接,ln -sfn domain/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'),
       ],

和 in.env 我把:

FILESYSTEM_DRIVER = public

所以我找到了这样的解决方案:首先我删除了我用 n -sfn domain/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',
        ],

之后,请求存储 function,它将在 public_html 中创建存储文件夹。 您的旧文件可能不会出现在那里(在将根更改为“存储”之前的文件),您可以从域中的存储文件中复制不存在的数据。

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM