dousou2911 2017-07-06 18:10
浏览 82
已采纳

在laravel 5.4(存储文件夹)中更改默认的“符号链接”文件夹

I'm making a new version of my site with laravel 5.4 and want to keep the same links than my old site has.

My old site has links images like this: domain.com/uploaded/cat.jpg

In laravel, its necesary to create a symbolic link to show the stored images but it saved them with a default folder named storage", like this: domain.com/storage/cat.jpg

How can i change the default name to "uploaded" or whatever?

I tried to change url inside the file \config\filesystems.php with this:

Before

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

After

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

and my controller

$request->file('image')->storeAs('public', 'example.jpg');
  • 写回答

3条回答 默认 最新

  • douduiti3040 2017-07-06 19:20
    关注

    Make sure you've created a symlink.

    According to your configuration, you can run this command :

    ln -s storage/app/public public/uploaded
    

    Then, you can access your files :

    Storage::disk('public')->url('example.jpg')
    

    Or simply using asset() helper :

    asset('uploaded/example.jpg');
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥20 数学建模数学建模需要
  • ¥15 c语言数据结构实验单链表的删除
  • ¥15 关于#lua#的问题,请各位专家解答!
  • ¥15 什么设备可以研究OFDM的60GHz毫米波信道模型
  • ¥15 不知道是该怎么引用多个函数片段
  • ¥30 关于用python写支付宝扫码付异步通知收不到的问题
  • ¥50 vue组件中无法正确接收并处理axios请求
  • ¥15 隐藏系统界面pdf的打印、下载按钮
  • ¥15 基于pso参数优化的LightGBM分类模型
  • ¥15 安装Paddleocr时报错无法解决