Skip to content

Allow to resolve known mime type to file extension #12918

Open
@mvorisek

Description

@mvorisek

Description

Mime type to file extension is already supported by FILEINFO_EXTENSION but it is impossible to specify the mime type :).

I expect code like:

$mimetype = 'application/zip';
$finfo = finfo_open(FILEINFO_EXTENSION);
var_dump(finfo_buffer($finfo, $mimetype, FILEINFO_EXTENSION)); // notice $mimetype is mime type not file data

to dump zip.

It should be possible to find the file magic data by iterating the magic data like in https://github.com/file/file/blob/FILE5_45/src/softmagic.c#L135, the mime/ext is defined in https://github.com/file/file/blob/FILE5_45/src/file.h#L371.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions