Why may not the type of mime be correctly determined?

让人想犯罪 __ 提交于 2021-02-11 18:17:08

问题


please help. I can not understand why my loaded jpeg picture is determined by the wrong mime type

correct option must be image/jpeg

        $mime_types = ['image/bmp', 'image/gif', 'image/jpeg', 'image/png'];

        Validator::extend('is_image_array', function($attribute, $values, $params, $validator) use ($mime_types) {

            foreach ($values as $k => $value) {
                $f = finfo_open();

                $result = finfo_buffer($f, base64_decode($value), FILEINFO_MIME_TYPE);
                
                dd($f, $value,$result, $mime_types);
                if ( !in_array($result, $mime_types)){
                    return false;
                }
            }
            return true;
        });

来源:https://stackoverflow.com/questions/62521824/why-may-not-the-type-of-mime-be-correctly-determined

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!