Файловый менеджер - Редактировать - /home/clickysoft/public_html/jm5-api.clickysoft.net/app/Rules/ValidateImage.php
Назад
<?php namespace App\Rules; use Illuminate\Contracts\Validation\InvokableRule; class ValidateImage implements InvokableRule { /** * Run the validation rule. * * @param string $attribute * @param mixed $value * @param \Closure(string): \Illuminate\Translation\PotentiallyTranslatedString $fail * @return void */ public function __invoke($attribute, $value, $fail) { $allowed_formats = ['jpg', 'jpeg', 'png']; if (is_file($value)){ $ext = $value->getClientOriginalExtension(); if (!in_array($ext, $allowed_formats)) $fail('Image for product #:position should be a valid image/base64 of type jpg, jpeg, png'); }else if (!preg_match('/^data:image\/(jpeg|png|jpg);base64,/', $value)) $fail('Image for product #:position should be a valid image/base64 of type jpg, jpeg, png'); } }
| ver. 1.4 |
Github
|
.
| PHP 8.1.29 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка