Zend Framework how to set headers

前端 未结 5 1812
天命终不由人
天命终不由人 2020-12-13 09:08

I have a question, how can I do something like this:

header(\"Content-Disposition: inline; filename=result.pdf\"); 
header(\"Content-type: application/x-pdf\         


        
5条回答
  •  一向
    一向 (楼主)
    2020-12-13 10:08

    My guess is that you're doing something like:

    $this->getResponse()
            ->setHeader('Content-Disposition:inline', ' filename=result.pdf')
            ->setHeader('Content-type', 'application/x-pdf');
    fpassthru($filename);
    exit();
    

    or something.

    The response here will never be rendered (which renders the headers). The response is rendered during post-action printing, usually.

    You will have to directly set the headers (as you noted in the non-oo code), or use $this->getResponse()->sendHeaders() directly.

提交回复
热议问题