douxiao0400 2014-05-19 23:23
浏览 10

尝试更改标题内容类型,但它没有任何效果

I'm trying to get a pdf generated by dompdf to download, so I wrote a function that returns dompdf's output, then I changed the headers of the page to include Content-type: application/pdf, the only problem is for some reason is the response header is Content-type: text/html anyways. It is a valid pdf file and everything, so I'm kind of at a loss as to why changing the content type isn't working.

public function couponDownload($location_uniqid = null) {
    $this->autoRender = $this->layout = false;

    // Set data
    $account = $this->Account->getAccount($this->Auth->user('company_id'));
    $data['Location'] = $account['Location'];

    // Set headers      
    header('Content-type: application/pdf');
    header('Content-Description: File Transfer');
    header('Content-Disposition: attachment; filename="coupon.pdf"');
    header('Content-Transfer-Encoding: binary');

    // Generate pdf
    echo $this->Location->generateCouponPdf($data); 
}
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
    • ¥15 java写代码遇到问题,求帮助
    • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
    • ¥15 有了解d3和topogram.js库的吗?有偿请教
    • ¥100 任意维数的K均值聚类
    • ¥15 stamps做sbas-insar,时序沉降图怎么画
    • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
    • ¥15 关于#Java#的问题,如何解决?
    • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
    • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计