In this line
$path->move(public_path('images/post_images'), $image);
Make sure it's your path not a tutorial path, but should work if you have an applicable path.
in laravel 6 video the developer is using this method to save data ( but how to store image using this way, like 2nd method):
Post::create($request->validate([
'post_name' => 'required|unique:posts',
'post_description' => 'required',
'post_slug' => 'required',
'post_image' => 'required|image',
]));
or
$post = Post::create($request->all());
this is another method which is saving image in specified location :
$request->validate([
'post_name' => 'required|unique:posts',
'post_description' => 'required',
'post_slug' => 'required',
'post_image' => 'required|image',
]);
$post = new Post;
$post->post_name = $request->post_name;
$post->post_description = $request->post_description;
$post->post_slug = $request->post_slug;
$path = $request->file('post_image');
$image = $path->getClientOriginalName();
$path->move(public_path('images/post_images'), $image);
$post->post_image = $image;
$post->save();
return redirect('/posts');
Please or to participate in this conversation.