PHP读写tbz文件
您好,我想下载 tbz 格式的文件。所以我首先需要下载 tbz 文件,所以我首先使用以下代码读取它并写入服务器上的本地目录:
ini_set("memory_limit","15M");
set_time_limit(1600);
if($result){
$write_handle=fopen("temp/$filename", 'a');
while (!feof($handle)) {
$contents = fread($handle, 8192);
echo "<pre>";
echo strlen($contents);
echo time()-$time_start;
echo "</pre>";
fwrite($write_handle, $contents);
}
echo $contents;
fclose($write_handle);
}
文件就在那里,但是当我尝试在其上使用 linux 的 tar -xjf 命令时,它说: 存档中出现意外的 EOF
。那么会出现什么问题呢?
我实际上需要使用该 tbz 文件内的文件,所以有没有办法做到这一点。文件大小几乎超过1GB。
Hi I want to download a file that is in tbz format. So I first need to download tbz file so I am first reading it and writing to local directory on my server using the following code:
ini_set("memory_limit","15M");
set_time_limit(1600);
if($result){
$write_handle=fopen("temp/$filename", 'a');
while (!feof($handle)) {
$contents = fread($handle, 8192);
echo "<pre>";
echo strlen($contents);
echo time()-$time_start;
echo "</pre>";
fwrite($write_handle, $contents);
}
echo $contents;
fclose($write_handle);
}
And the files is there but when I try to tar -xjf command of linux on it, it says :Unexpected EOF in archive
. So what can be problem?
I actually need to use the file inside that tbz file so is there a way to do so. File size is almost more than 1GB.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
嗯,你只给出了你的代码的一部分,但是阅读你的问题并考虑到你说:
文件大小几乎超过 1GB。
我必须问..
您是否使用 set_time_limit() 所以脚本持续时间足够长,并且 php.ini 中的内存限制 因此脚本具有内存够用吗?
Hmz, you only give a part of your code, but reading your issue and considering you said:
File size is almost more than 1GB.
I have to ask..
Are you using set_time_limit() so the scripts lasts long enough and memory_limit in php.ini so the script has enough memory?