laravel5.5.49版本调用Validete类验证image类型,jpg图片验证不通过

ValidatesAttributes文件搜索
validateImage方法,源码如下
/**
     * Validate the MIME type of a file is an image MIME type.
     *
     * @param  string  $attribute
     * @param  mixed   $value
     * @return bool
     */
    public function validateImage($attribute, $value)
    {
        return $this->validateMimes($attribute, $value, ['jpeg', 'png', 'gif', 'bmp', 'svg', 'webp']);
    }

在数组里添加jpg后即可,修改后的源码如下

/**
     * Validate the MIME type of a file is an image MIME type.
     *
     * @param  string  $attribute
     * @param  mixed   $value
     * @return bool
     */
    public function validateImage($attribute, $value)
    {
        return $this->validateMimes($attribute, $value, ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'svg', 'webp']);
    }

这样,上传jpg后缀的图片调用Validate验证image时就可以验证通过了。

这个问题在laravel8.17.0版本才修复

posted @ 2022-03-09 09:18  骑着新浪狂奔  阅读(223)  评论(0编辑  收藏  举报