步骤是这样的:
1. 用PHP调用System命令:system("tar -zcf $zipFile $tempPath", $retval);
2. 通过header方式将文件提供下载:
set_time_limit(0);
header("Content-Encoding: none");
header("Content-type: application/x-gzip");
header("Cache-Control: private");
header("Accept-Ranges: bytes");
header("Accept-Length: ".filesize($zipFile));
header("Content-Disposition: attachment; filename=".basename($zipFile));
header('Pragma: no-cache');
header('Expires: 0');
readfile($zipFile);
问题: 下载完后打不开文件,Window,Linux下测试均不行。测试时,如果用zip命令打包,则可以下载后可以正确打开,或者提供输出的文件,即指定$zipFile=非tar.gz格式的文件也能正确下载并打开。请问问题是出在哪呢?
1. 用PHP调用System命令:system("tar -zcf $zipFile $tempPath", $retval);
2. 通过header方式将文件提供下载:
set_time_limit(0);
header("Content-Encoding: none");
header("Content-type: application/x-gzip");
header("Cache-Control: private");
header("Accept-Ranges: bytes");
header("Accept-Length: ".filesize($zipFile));
header("Content-Disposition: attachment; filename=".basename($zipFile));
header('Pragma: no-cache');
header('Expires: 0');
readfile($zipFile);
问题: 下载完后打不开文件,Window,Linux下测试均不行。测试时,如果用zip命令打包,则可以下载后可以正确打开,或者提供输出的文件,即指定$zipFile=非tar.gz格式的文件也能正确下载并打开。请问问题是出在哪呢?
解决方案 »
- 请教preg_match() [function.preg-match]: Compilation failed: nothing to repeat at
- Linux 安装配置XAMPP 安装报错?(在RedHat9下面安装的)
- 关于PHP的表单递交,于变量传递问题
- 求教:是如何用正则表达中文
- 这需求我没见过,谁能给解决一下,SQL的~~~
- 求救:机器升级后php环境出现错误!
- php开发进销存管理系统
- 统计特定时间每个人在每个栏目发了多少篇文章
- 讨论一下mysql中like和match+against的效率问题
- 又是session的问题,那位大哥帮帮忙啊,很急啊
- PHP网站调用数据库函数修改
- 如何用PHP查找字符串是否有某中文字符
tar.gz文件的MIME类型应该是 application/x-compressed-tar
即 header("Content-type: application/x-compressed-tar“);