首页 > 解决方案 > 刀片文件上未显示图像

问题描述

为什么即使在执行符号链接之后,我的图像也没有显示在实时托管的刀片文件中,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) }}

标签: phplaravellaravel-5eloquentsymlink

解决方案


您可以使用asset()助手

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

或者Storage门面

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

推荐阅读