Answer the question
In order to leave comments, you need to log in
Laravel 6 How to properly validate svg?
Good afternoon. Faced the problem of svg validation.
I'm trying to validate by extension: 'icon' => 'max:50|mimes:svg',
But the icons are loaded only if there are lines in the file:
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
Answer the question
In order to leave comments, you need to log in
Why does svg start with some kind of tag? Let it start like it should. I had a similar situation when I did not skip docx with docx mime and the problem was in the self-made editor with which the file was created. To check by extension, make a Rule with a check
public function passes($attribute, $value)
{
// проверка на совпадение расширения файла с svg
return $value->getClientOriginalExtension() === File::EXTENSION__SVG;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question