1

Hii Im making project for school, and its a site where users can upload videos, I set the max upload file to 85MB on php.ini, the problem is that if I upload files larger than this then QueryException is thrown, same happens if I fill a description too large or a name too large.

This is the store method on my VideoController (even having max:255 on description throws QueryException anyways)

public function store(Request $request)
{

    $request->validate([
        'title'=>'required|unique:videos|max:55',
        'desc'=>'required|max:255',
        'video'=>'required',
    ]);

    $pathV=$request->file('video')->store('videos','public');
    $user = Auth::user()->id;
    Video::create(['title'=>$request->title,
                    'cont'=>$pathV,
                    'desc'=>$request->desc,
                    'user'=>$user
        ]);
    $videos=Video::all();
    return view('videos.all',compact('videos'));
}

1 Answer 1

2

Add this validation rule to the validation array - file|max:85000

 $request->validate([
        'title' => 'required|unique:videos|max:55',
        'desc' => 'required|max:255',
        'video' => 'required|file|max:85000'
    ]);
Sign up to request clarification or add additional context in comments.

3 Comments

I added it but when I upload a video and exceed the max limit (of title, description or file size) it seems like its trying to store it anyways and it doesnt validate. Im still getting the queryexception error. If you need to review more classes I can provide it without problem.
Replace 'required|file|max:85000' with this - 'required|file|mimes:mp4,x-flv,x-mpegURL,MP2T,3gpp,qt,x-msvideo,x-ms-wmv|max:85000'
It keeps showing the queryException error for title,desc or video whatever exceeds the limit. I dont know why, it shouldnt do it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.