简体   繁体   English

有没有办法用 PHPPresentation 下载 pptx 文件?

[英]Is there a way to download pptx file with PHPPresentation?

I am using PHPPresentation for the first time and everything works fine, but I don't want to save file to some destination, I want to download that file through web browser.我第一次使用 PHPPresentation,一切正常,但我不想将文件保存到某个目的地,我想通过网络浏览器下载该文件。 How to do that?怎么做?

Please help.请帮忙。

This is code to save file on some destination这是将文件保存在某个目的地的代码

$oWriterPPTX = IOFactory::createWriter($objPHPPresentation, 'PowerPoint2007');
$oWriterPPTX->save(__DIR__ . "/sample.pptx");

PHPPresentation should work similiar to PHPExcel. PHPPresentation 应该与 PHPExcel 类似。

According to this question you can use:根据这个问题,您可以使用:

$oWriterPPTX->save('php://output');

Try this code试试这个代码

 header("Content-Type: application/vnd.openxmlformats-officedocument.presentationml.presentation");
    header("Content-Disposition: attachment; filename=test.pptx");
    $oWriterPPTX = IOFactory::createWriter($this->objPhpPresentation,'PowerPoint2007' );
    $oWriterPPTX->save('php://output');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM