Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

anonymouse703's avatar

The news image failed to upload.

Hello guys, It was working before... I just got new images from my client and when I upload the new pictures I got this error:

The news image failed to upload.

My first thought was to maximize the size up to 5mb in my validator but still the error occurred. max:5100

Here is my controller

 public function store(Request $request)
    {
        $this->validate($request, [
            'title'=>'required',
            'description'=>'required',
            'news_image' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048'
        ]);
            
      
        $fileName = $request->news_image->getClientOriginalName(); 

        if($request->hasFile('news_image')) {

            $news = new News();
            $news->posted_by = Auth::id();
            $news->title = $request->title;
            $news->description = $request->description;
            $news->file_name = $fileName;
            $news->save();

            $request->news_image->move(public_path('news_images'), $fileName);

            session()->flash('save', 'Record Successfully Saved.');
        }
        
        return redirect()->route('news.index');
    }


What did I miss guys?

0 likes
3 replies

Please or to participate in this conversation.