本文介绍了即时压缩并下载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我正在尝试编写一个用于动态压缩和下载的php脚本.
我在尝试使其在此特定Web服务器上工作时遇到很多问题.
这是我的代码:
Hi all,
I''m trying to write a php script for on the fly compression and download.
I have lots of problems trying to get it working on this particular web server.
This is my code:
header(''Content-Type: application/octet-stream'');
header(''Content-disposition: attachment; filename="file.zip"'');
set_time_limit(0);
//$fp = proc_open(''zip -r9 - foldertocompress'', ''w'');
//$fp = system(''zip -r9 '');
// pick a bufsize that makes you happy (8192 has been suggested).
$bufsize = 8192;
$buff = '''';
while( !feof($fp) ) {
$buff = fread($fp, $bufsize);
echo $buff;
flush();
}
我正在尝试不同的命令,以查看哪些有效,以及有趣的事情
分配给$ fp的两行就开始下载了吗?我真的不明白,$ fp从哪里获取数据?
谢谢,
Brian
I am trying out different commands to see which works, and the amusing thing
is that it starts to download even with the 2 lines assigning to $fp commented out?!
I really don''t understand this, where is $fp getting its data from?
Thanks,
Brian
推荐答案
这篇关于即时压缩并下载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!