bjorno43 / ImageSecure

PHP Library to securely handle images uploaded by users

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Strange warning accussing any mimetype of not being an image.

gusbemacbe opened this issue · comments

The result is:

File: produto-01.jpeg is not an image. The file is removed!
Your images can be viewed here:

In the config file:

define("R_PATH", __DIR__);
define("F_PATH", R_PATH.'/assets/imagens/produtos');
define("H_FILE", true);

In the file imgupload.class:

    private function check_img_mime($tmpname)
    {
        $finfo       = finfo_open(FILEINFO_MIME_TYPE);
        $mtype       = finfo_file($finfo, $tmpname);
        $this->mtype = $mtype;

        if (strpos($mtype, '/assets/imagens/produtos/') === 0)
        {
            return true;
        }

        return false;

        finfo_close($finfo);
    }

The database:

imagem

Envio, Substituição e Actualização.zip

commented

This is not an issue, but an error on your own side. You've changed if(strpos($mtype, 'image/') === 0){ to if (strpos($mtype, '/assets/imagens/produtos/') === 0), which doesn't work. That line is not a directory line. It's a MIME type. You should NEVER change it.