Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel Validation on video file not working

I am workng on video hosting website in laravel,

  1. I have a from which user can enter data in fields
  2. In form user can upload a video file

    {{ Form::file('filename', isset($movie->filename) ? $movie->filename: Input::old('filename')) }}

my validator code is given below

    $input = Input::all();
    $validator = Validator::make($input,
        array(
            // other validations working fine
            'filename' => 'required|mimes:video/mp4,video/x-flv,application/x-mpegURL,video/MP2T,video/3gpp,video/quicktime,video/x-msvideo,video/x-ms-wmv'
        ));

I have checked this and this

Even I have checked MIME type of a file for testing purpose via

dd(mime_content_type($_FILES['filename']['tmp_name']));

it returns video/mp4 , even it is in validation check. Moreover required validation is also working good. Then why Mime Type validtion not working fine ? Thanks

like image 403
Tayyab Hussain Avatar asked Oct 16 '25 14:10

Tayyab Hussain


1 Answers

You should use mimes validator rule like this:

'filename' => 'required|mimes:mp4,x-flv,x-mpegURL,MP2T,3gpp,quicktime,x-msvideo,x-ms-wmv'
like image 179
Limon Monte Avatar answered Oct 18 '25 07:10

Limon Monte