public static function getMimeType($filename = '')
    {
        $ext = strtolower(substr($filename, strrpos($filename, '.')));
        switch ($ext) {
            case '.jpeg': case '.jpg': $mimetype = 'image/jpeg'; break;
            case '.gif': $mimetype = 'image/gif'; break;
            case '.png': $mimetype = 'image/png'; break;
            case '.txt': $mimetype = 'text/plain'; break;
            case '.html': case '.htm': $mimetype = 'text/html'; break;
            case '.zip': $mimetype = 'application/x-zip-compressed'; break;
            default: $mimetype = 'application/octet-stream';
        }
        return $mimetype;
    }