无法从“公共/存储”文件夹加载图像

时间:2019-05-24 13:02:04

标签: laravel-5.7

图像无法显示。

$table->string('image'); 

这是我将数据迁移到db时使用的方法。

public function store(CreatePostsRequest $request)
    {
        // upload the image to storage
        $image = $request->image->store('posts');
        // create the post
        $post = Post::create([
            'title' => $request->title,
            'description' => $request->description,
            'content' => $request->content,
            'image' => $image,
            'published_at' => $request->published_at,
            'category_id' => $request->category
        ]);
        if ($request->tags) {
            $post->tags()->attach($request->tags);
        }
        // flash a message
        session()->flash('success', 'Post Created Successfully.');

        // Redirect
        return redirect(route('posts.index'));
    }

0 个答案:

没有答案