【问题标题】:Images are not showing on blade file刀片文件上未显示图像
【发布时间】:2020-03-08 16:34:52
【问题描述】:

为什么即使在执行符号链接之后,我的图像也没有显示在实时托管的刀片文件中,ps:-它在 localhost 上运行良好

后控制器:

 public function createpost(Request $request)
    {

       Post::create(
        [
            'user_id'=>$request->user_id,
            'post_title'=>$request->post_title,
            'post_body'=>$request->post_body,
            'post_image'=>$request->file('post_image')->store('public'),
            'status'=>1
       ]);
       echo "Recorded Successfully";
       echo "<a href='/post'>Click here</a> to go back";
     }

文件系统.php

'disks' => [

        'local' => [
            'driver' => 'local',
            'root' => storage_path('app'),
        ],

        'public' => [
            'driver' => 'local',
            'root' => storage_path('public'),
            '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'),
        ],

    ],

Blade.php 文件

{{url('storage/'.$post->post_image) }}

【问题讨论】:

    标签: php laravel laravel-5 eloquent symlink


    【解决方案1】:

    您可以使用asset() 助手

    {{ asset('storage/' . $post->post_image) }}
    

    或者Storage门面

    {{ Storage::url($post->post_image) }}
    

    【讨论】:

    • 没用啊兄弟!你能通过链接并建议它有什么问题吗?链接:-jcisatashidham.com/blog
    • 图片显示效果很好
    • 谢谢先生的关心!我弄错了我的网址
    猜你喜欢
    • 1970-01-01
    • 2021-05-26
    • 2020-09-13
    • 2019-12-06
    • 2021-10-17
    • 2020-02-05
    • 2018-12-12
    • 2017-03-12
    • 1970-01-01
    相关资源
    最近更新 更多