php artisan storage:共享主机上的链接未显示图像

问题描述

我一直在开发laravel应用程序,因此出于安全原因,我将所有公共文件都放在了public_html的基本文件夹中,而其他文件都放在了public_html / secondBase中。

现在,当我执行命令: php artisan storage:link 时,出现以下错误。

 ErrorException

  symlink(): No such file or directory

  at vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php:265
    261|      */
    262|     public function link($target,$link)
    263|     {
    264|         if (! windows_os()) {
  > 265|             return symlink($target,$link);
    266|         }
    267|
    268|         $mode = $this->isDirectory($target) ? 'J' : 'H';
    269|

我厌倦了下面的解决方案

<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;

public function register()
{
    $this->app->bind('path.public',function() {
        return base_path() . '/public_html/base';
    });
}

我尝试过的第二种方法是使文件 symlink.php ,但是图像仍然损坏。

symlink.php

<?php 
symlink('/home/hmm/public_html/secondBase/storage/app/public','/home/hmm/public_html/base/storage');

最后我沿着这条路线出现了第一个错误。

Route::get('/clear',function () {
       
    Artisan::call('route:clear');
    Artisan::call('storage:link',[] );
});

感谢您的帮助。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)