src/FlexiPeeHP/Priloha.php
public static function download($object, $format = 'pdf',
                                    $attachmentID = null)
    {
        $attachments = self::getAttachmentsList($object);

        if (isset($attachmentID) && !array_key_exists($attachmentID,
                $attachments)) {
            $object->addStatusMessage(sprintf(_('Attagment %s does no exist'),
                    $attachmentID), 'warning');
        }

        $attachmentBody = $object->doCurlRequest(self::getDownloadUrl($object),
            'GET');
        header('Content-Description: File Transfer');
        header('Content-Type: application/octet-stream');
        header('Content-Transfer-Encoding: binary');
        header('Expires: 0');
        header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
        header('Pragma: public');
        header('Content-Disposition: attachment; filename='.$object->getEvidence().'_'.$object.'.'.$format);
        header('Content-Length: '.strlen($attachmentBody));
        echo $attachmentBody;
    }
public static function download($object, $format = 'pdf',
                                    $attachmentID = null)
    {
        $attachments = self::getAttachmentsList($object);

        if (isset($attachmentID) && !array_key_exists($attachmentID,
                $attachments)) {
            $object->addStatusMessage(sprintf(_('Attagment %s does no exist'),
                    $attachmentID), 'warning');
        }

        $attachmentBody = $object->doCurlRequest(self::getDownloadUrl($object),
            'GET');
        header('Content-Description: File Transfer');
        header('Content-Type: application/octet-stream');
        header('Content-Transfer-Encoding: binary');
        header('Expires: 0');
        header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
        header('Pragma: public');
        header('Content-Disposition: attachment; filename='.$object->getEvidence().'_'.$object.'.'.$format);
        header('Content-Length: '.strlen($attachmentBody));
        echo $attachmentBody;
    }
public static function download ( $ object , $ format = 'pdf' , $ attachmentID = null ) { $ attachments = self :: getAttachmentsList ( $ object ) ; if ( isset ( $ attachmentID ) && ! array_key_exists ( $ attachmentID , $ attachments ) ) { $ object -> addStatusMessage ( sprintf ( _ ( 'Attagment %s does no exist' ) , $ attachmentID ) , 'warning' ) ; } $ attachmentBody = $ object -> doCurlRequest ( self :: getDownloadUrl ( $ object ) , 'GET' ) ; header ( 'Content-Description: File Transfer' ) ; header ( 'Content-Type: application/octet-stream' ) ; header ( 'Content-Transfer-Encoding: binary' ) ; header ( 'Expires: 0' ) ; header ( 'Cache-Control: must-revalidate, post-check=0, pre-check=0' ) ; header ( 'Pragma: public' ) ; header ( 'Content-Disposition: attachment; filename=' . $ object -> getEvidence ( ) . '_' . $ object . '.' . $ format ) ; header ( 'Content-Length: ' . strlen ( $ attachmentBody ) ) ; echo $ attachmentBody ; }
Send "download" headers first and then file itself

@param FlexiBeeRO $object
@param int|string $attachmentID
Send download headers first and then file itself