Jaykumar Patil
Jaykumar Patil

Reputation: 359

Laravel Validator mime-types except certain types

In my web application, I am allowing user to upload files and the application stores the file in Aws s3. I am using laravel 5.0 and want to validate file types using Validator class. I know the rule

mimes:jpeg,bmp,png

But My problem is I want to allow all files EXCEPT 'php,html,js'.

Is there any rule for It? or any custom function.

Upvotes: 1

Views: 1923

Answers (2)

omarjebari
omarjebari

Reputation: 5519

You should write your own (reusable) custom validator. eg for Laravel 5.3 see:

https://laravel.com/docs/5.3/validation#custom-validation-rules

Upvotes: 0

davsp
davsp

Reputation: 2189

Unfortunately you can only whitelist in the mimes validation, there is no blacklist function.

Upvotes: 1

Related Questions