brandonsavage / Upload

File uploads with validation and storage strategies
MIT License
1.67k stars 315 forks source link

getMimetype() return empty value #60

Open macrob opened 9 years ago

macrob commented 9 years ago
need to change:

File.php line 202;

public function getMimetype() { if (!isset($this->mimeType)) { $finfo = new \finfo(FILEINFO_MIME); $mimetype = $finfo->file($this->getPathname()); $mimetypeParts = pregsplit('/\s[;,]\s_/', $mimetype); $this->mimetype = strtolower($mimetypeParts[0]); unset($finfo); }

    return $this->mimetype;
}

to

public function getMimetype()
{
    if (!isset($this->mimetype)) {
        $finfo = new \finfo(FILEINFO_MIME);
        $mimetype = $finfo->file($this->getPathname());
        $mimetypeParts = preg_split('/\s*[;,]\s*/', $mimetype);
        $this->mimetype = strtolower($mimetypeParts[0]);
        unset($finfo);
    }

    return $this->mimetype;
}