#### Laravel 5.8: Throw new PostTooLargeException [duplicate]

I’m working with Laravel 5.8 and I wanted to upload two video files to the Server, so I coded this:

if ($request->file('prd_video') AND$request->file('prd_video_preview')) {
$video = Request::file('prd_video');$videoname = $video->getClientOriginalName();$path = public_path().'/upload/video/products/';
$request->file('prd_video')->move($path, $videoname);$video_preview = Request::file('prd_video_preview');
$videoname_preview =$video_preview->getClientOriginalName();
$path_preview = public_path().'/upload/video/products/preview/';$request->file('prd_video_preview')->move($path,$videoname_preview);
}


But now I get the error:

Illuminate  Http  Exceptions  PostTooLargeException
No message


Which is referring to vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php:

public function handle($request, Closure$next)
{
$max =$this->getPostMaxSize();

if ($max > 0 &&$request->server('CONTENT_LENGTH') > $max) { throw new PostTooLargeException; } return$next(\$request);
}


And here is the screenshot.

So what’s going wrong here? I have already defined .user.ini at public directory of my project like this:

upload_max_filesize = 40M
post_max_size = 40M


So if you know how to solve this problem, please let me know…

Source: Laravel