我的脚本有问题,当我在创建后尝试下载 ZIP 文件时 - apache 读取它们而不是下载!
我使用 zipstream.php 类(https://github.com/maennchen/ZipStream-PHP)
如何配置 apache(在 Ubuntu 上运行)以允许下载带有 ZIP 扩展名的文件?
谢谢 !
我正在使用的代码:
<?php
if($_GET['download'] == "ok")
{
$id = $_GET['id'];
$content = "TEST";
$mysql = $db_1->query("select result from testing where id='$id'");
$row = mysql_fetch_assoc($mysql);
$content .= $row['result'];
$file_opt = array(
'time' => time() - 2 * 3600,
'comment' => 'Simple Comment !',
);
$zip = new ZipStream('test.zip', array(
'comment' => 'Simple Comment !'
));
$zip->add_file('test.txt', $content, $file_opt);
$zip->finish();
exit;
}
注意:问题是当我从 JQUERY 调用文件时他不会下载,但是当我直接浏览它时他会正确下载!