为什么即使执行符号链接后,我的图像也无法显示在实时托管的刀片文件中,ps:-在本地主机上运行良好
PostController:
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";
}
Filesystems.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) }}
答案 0 :(得分:0)
您可以使用asset()
助手
{{ asset('storage/' . $post->post_image) }}
或者Storage
门面
{{ Storage::url($post->post_image) }}