mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-19 16:32:15 +00:00
DisabledMimetypes.php validation rule fix
This commit is contained in:
32
app/Rules/DisabledMimetypes.php
Normal file
32
app/Rules/DisabledMimetypes.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Rules;
|
||||
use Illuminate\Contracts\Validation\Rule;
|
||||
|
||||
class DisabledMimetypes implements Rule
|
||||
{
|
||||
/**
|
||||
* Determine if the validation rule passes.
|
||||
*
|
||||
* @param string $attribute
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
*/
|
||||
public function passes($attribute, $value)
|
||||
{
|
||||
$mimetype_blacklist = explode(',', get_setting('mimetypes_blacklist'));
|
||||
$file_mimetype = explode('/' ,$value->getMimeType());
|
||||
|
||||
return ! array_intersect($file_mimetype, $mimetype_blacklist);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation error message.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function message()
|
||||
{
|
||||
return 'Type of this mime type is not allowed.';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user