【问题标题】:Issue displaying images with Laravel file manager. Routes question使用 Laravel 文件管理器显示图像时出现问题。路线问题
【发布时间】:2020-12-17 11:06:21
【问题描述】:

我弄乱了让 UniSharp / laravel-filemanager 在服务器上工作的路径。在本地模式下它工作得很好,但现在我正在改变在线模式下的生产路线,我一点都不清楚。

问题在于它加载了图像,但它们既没有显示在页面上,也没有显示在文件管理器本身中。在文件管理器中,我可以看到一个带有十字的红色方块(作为错误)。 让我们看看是否有人知道如何编写正确的路线。我尝试了很多东西,但我一团糟。

服务器文件脚手架:

  • server_files
  • my_laravel_app
  • public_html
    • 另一个文件

Laravel 中的配置文件system.php 文件:

'disks' => [
        'local' => [
            'driver' => 'local',
            'root' => storage_path('app'),
        ],
        'public' => [
            'driver' => 'local',
            'root' => storage_path('public_html'),
            'url' => env('APP_URL').'/storage',
            'visibility' => 'public',
        ],
        's3' => [
            'driver' => 's3',
            'key' => env('AWS_ACCESS_KEY_ID'),
            'secret' => env('AWS_SECRET_ACCESS_KEY'),
            'region' => env('AWS_DEFAULT_REGION'),
            'bucket' => env('AWS_BUCKET'),
            'url' => env('AWS_URL'),
            'endpoint' => env('AWS_ENDPOINT'),
        ],
    ],
  'links' => [
    public_path('storage') => storage_path('app/public'),
],

我有,filemanager的lfm.php默认上传路径:

'disk'  => 'public',

如果它有帮助,这是我在 public_html 上的 index.php:

if (file_exists(__DIR__.'/../my_app_laravel/storage/framework/maintenance.php')) {
    require __DIR__.'/../my_app_laravel/storage/framework/maintenance.php';
}
require __DIR__.'/../my_app_laravel/vendor/autoload.php';
$app = require_once __DIR__.'/../my_app_laravel/bootstrap/app.php';

这是 ServiceProviders.php

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

文件系统中的正确路径应该如何让文件管理器可以访问图像并显示它们?

注意:public_html 文件夹有符号链接,您可以在 filesystem.php 中看到。

【问题讨论】:

    标签: laravel image


    【解决方案1】:

    我检查了路线,我临时解决了:

    我变了:

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

    现在我可以在文件管理器和网络应用程序中上传和查看图像。但是现在的问题是用户可以访问图片url,看到文件夹的私有路由:

    http//mi_lar_app/storage/app/public/photos/31/art_1/fig_1.0.png
    

    一些帮助????

    如果您有类似的问题,我在这种情况下所做的过程是创建一个带有路由的符号链接(我创建了一个 php 文件,因为我无法访问我的服务器上的 SSH):

    <?php
        /*__DIR__ is the directory file, where you save this file.php */
        $mytargetDIR = __DIR__.'/../mi_lar_app/storage';
        $mylinkDIR = __DIR__.'/storage';
            symlink($mytargetDIR,$mylinkDIR);
        echo 'Todo ok/ Symlink process successfully completed';
    ?>
    

    重要的是,请记住清理缓存并路由每次更改。如果您没有 SSH 访问权限:

    <?php
        Artisan::call('cache:clear');
        Artisan::call('config:cache');
        Artisan::call('route:cache');
        Artisan::call('view:clear');
          return 'Todo limpio/All is cleaned';
    ?>
    

    接下来这个小解释,对我有帮助吗?? :)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-02-13
      • 2022-12-16
      • 2019-05-11
      • 1970-01-01
      • 1970-01-01
      • 2010-10-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多