【发布时间】:2014-02-05 13:54:09
【问题描述】:
我正在使用 PHPPowerpoint 创建一个带有一些图表的 pptx 文件,并且将它存储在与 PHP 脚本相同的文件夹中没有问题。 PHPPowerpoint 会自行完成。
我想在创建 pptx 文件后下载它,到目前为止,我已经尝试了所有可以在网络上找到的选项。这就是我尝试在 atm 上做的方式。:
$file = str_replace('generate_report.php', 'export_download.pptx', __FILE__);
header('Content-Description: File Transfer');
header('Content-disposition: attachment; filename="' . $file . '"');
header('Content-Transfer-Encoding: binary');
header('Content-Type: application/vnd.openxmlformats-officedocument.presentationml.presentation');
header('Expires: 0');
header('Cache-Control: ');
header('Pragma: ');
flush();
ob_clean();
readfile($file);
执行脚本时没有下载任何内容。我的pptx是在服务器上创建的,可以打开,没问题。但它不会下载文件。我从这个线程中得到了内容类型:What is a correct mime type for docx, pptx etc?。我也尝试了许多其他类型。当我控制台记录我的响应时,我得到一个奇怪的字符串(很长),像这样开始:PKCTDD����[Content_Types].xml͗�n�0E�|E�-J��*�X����� +��������wBhE
也试过这个:
$handle = fopen($file, 'rb');
$buffer = '';
while (!feof($handle)) {
$buffer = fread($handle, 4096);
echo $buffer;
ob_flush();
flush();
}
fclose($handle);
谁能帮忙?
【问题讨论】:
标签: php powerpoint readfile phppowerpoint