2
votes

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

1
So what exactly happens in your validation? You say it's "not working fine" but that could mean any number of different problems are occurring. Do you get an error code? Incorrect output? The Flying Spaghetti Monster emerged from your monitor?Aiken

1 Answers

5
votes

You should use mimes validator rule like this:

'filename' => 'required|mimes:mp4,x-flv,x-mpegURL,MP2T,3gpp,quicktime,x-msvideo,x-ms-wmv'