I am doing a CMS in laravel and I am trying to upload a file in laravel more than 2MB and It displays that image failed to upload.
my controller code.
$this->validate($request ,[
'title' => 'required',
'featured' => 'required|image',
'content' => 'required',
'category_id' => 'required',
'tags' => 'required'
]);
$featured = $request->featured;
$featured_new_name = $featured->getClientOriginalName();
$featured->move('uploads/posts', $featured_new_name);
$post = Post::create([
'title' => $request->title,
'slug' => str_replace(' ', '-', $request->title),
'featured' => 'uploads/posts/' . $featured_new_name,
'content' => $request->content,
'category_id' => $request->category_id,
'user_id' => Auth::id()
]);
$post->tags()->attach($request->tags);
Session::flash('success', 'Post Created Sucessfully.');
return redirect()->route('posts');