ManaPHP\Http\Response::setAttachment PHP Method

setAttachment() public method

public setAttachment ( string $attachmentName ) : static
$attachmentName string
return static
    public function setAttachment($attachmentName)
    {
        if (isset($_SERVER['HTTP_USER_AGENT'])) {
            $userAgent = $_SERVER['HTTP_USER_AGENT'];
            if (Text::contains($userAgent, 'Trident') || Text::contains($userAgent, 'MSIE')) {
                $attachmentName = urlencode($attachmentName);
            }
        }
        $this->setHeader('Content-Description', 'File Transfer');
        $this->setHeader('Content-Type', 'application/octet-stream');
        $this->setHeader('Content-Disposition', 'attachment; filename=' . $attachmentName);
        $this->setHeader('Content-Transfer-Encoding', 'binary');
        $this->setHeader('Cache-Control', 'must-revalidate');
        return $this;
    }