当扩展名更改为.jpg或.gif或.png时,laravel mime类型验证不适用于.exe文件

时间:2019-04-02 08:32:01

标签: file-upload mime-types executable laravel-5.6

我想上传图像的mime类型工作正常,但是当我将可执行文件扩展名更改为图像扩展名Laravel不能dtetct时,它不是图像。

假设我们有一个包含example.exe的文件,例如,在更改了扩展名之后,我们将拥有example.png或example.gif或example.jpg文件,因此在上载laravel之后无法阻止上传具有假扩展名的可执行文件。 / p>

希望很快能帮助我。

$validation = Validator::make(
                    $input, 
                    [
                        'imageattachments.*' => 'required|mimes:jpg,jpeg,png,gif,bmp,svg,ico|max:2048
                    ],[
                        'imageattachments.*.required' => 'Please upload an image',
                        'imageattachments.*.mimes' => 'Only jpg,jpeg,png,gif,bmp,svg,ico images are allowed'
                    ]
                );

                if ($validation->fails()) {
                    return response()->json(['color' => 'bg-pink','message' => $validation->messages()->first() ]);
                }

0 个答案:

没有答案
相关问题