Mime-type check

Before to upload a file, your component checks the coherency of the header of a file. It should match with its own known mime-types / extensions pairs.
Mime check is not a security safe check because the file header can be edited by hand.
It only helps for the ergonomy to avoid uploading a corrupted file, but you can avoid it.

Mime detection

There are severals possibles ways to detect mime in php. Your component is trying the one it found possible, but it depends of your server configuration.
Here is the php code wich handles the differents ways:

switch($method)
{

    case 'system':
        if (!function_exists('system'))
            continue;

        $mime = system("file -i -b " . $file);
        break;

    case 'shell_exec':
        if (!function_exists('shell_exec'))
            continue;

        $mime = trim( @shell_exec( 'file -bi ' . escapeshellarg( $file ) ) );
        break;

    case 'mime_content_type':
        if (!function_exists('mime_content_type'))
            continue;
        $mime = mime_content_type($file);
        break;


    case 'finfo_file':
        if (!function_exists('finfo_file'))
            continue;
        $finfo = finfo_open(FILEINFO_MIME);
        $mime = finfo_file($finfo, $file);
        finfo_close($finfo);
        break;


    case 'image_check':
        $file_info = getimagesize($file);
        $mime = $file_info['mime'];
        break;

}



Troubleshooting

Specific file or extension

If it fails only with a certain type of files, then the problem do not comes from your component.
It can be a firewall, it can be a corrupted header

Always fails

If your component always fails to read a mime header:

1. Check your php modules.
Check the availability of the required methods (see before)

2. Disable Mime detection.

In your component configuration, you can disable the Mime-type detection (This option is not available in the sandbox)

Mime-check config


Get Started