简体   繁体   English

PHP:ZipArchive :: extractTo()尚未完成解压缩

[英]PHP: ZipArchive::extractTo() doesn't complete unzipping

I'm using ZipArchive to unzip files. 我正在使用ZipArchive解压缩文件。 It's working great, except for ONE file so far (it's 10.6MB, if that matters). 它工作得很好,除了到目前为止只有一个文件(如果重要的话,为10.6MB)。

The problem is, ZipArchive::extractTo() returns FALSE , and that's correct since if fails. 问题是, ZipArchive::extractTo()返回FALSE ,这是正确的,因为if失败。

BUT it doesn't completely fails: half of the file is being unzipped, and then it returns FALSE . 但是它并不会完全失败:文件的一半被解压缩,然后返回FALSE

As this method doesn't throw any Exception , FALSE is not really great to understand what happened in the middle of that unzipping journey. 由于此方法不会引发任何Exception ,所以FALSE并不是真正了解在解压缩过程中发生的事情的好方法。 If anyone already ran into that problem, i'd love some help :) Thanks! 如果有人已经遇到了这个问题,我很乐意提供一些帮助:)谢谢!

My problem is different, but I think you're running into a memory issue. 我的问题不同,但是我认为您遇到了内存问题。

Try to force this: 尝试强制这样做:

ini_set('memory_limit', '128M');
set_time_limit(0);

Also, try to get memory usage before and after script, and deal with the total: 另外,尝试获取脚本前后的内存使用情况,并处理总计:

$mem_before = memory_get_usage();
/* your script code here */
$mem_after = memory_get_usage();
printf('Memory used: %1$s bytes', ($mem_after - $mem_before));

Maybe this points you in the right direction. 也许这为您指明了正确的方向。 ;) ;)

Best! 最好!
R [R

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM