public static function is_extension_invalid($extension, $oldextension = '') {
        $extension = trim($extension);
        if ($extension === '' || $extension[0] === '.') {
            return true;
        }

        $mimeinfo = get_mimetypes_array();
        if ($oldextension !== '') {
            unset($mimeinfo[$oldextension]);
        }

        return array_key_exists($extension, $mimeinfo);
    }