weezelds Posted November 12, 2011 Share Posted November 12, 2011 Hello, I'm having trouble with zip_read. I made a zip of 2 plain 8k text files and zipped them w/ winrar using default settings. I opened the file w/ zip_open and then checked to make sure the return value was a valid resource, which it is. But when I try to use the return value of zip_read I get: Warning: zip_entry_name() expects parameter 1 to be resource, boolean given in xxx It is actually returning "1". According to the zip error codes I think this means "Multi-disk zip archives not supported". I have no idea what a 'multi-disk' zip file is. I've posted my code below. How can I get php to read through a zip file? Thanks $zip = zip_open($this->upload_path . $filename); if (is_resource($zip)) { $i = 0; while($zip_entry = zip_read($zip) && $i<500 ){ if($this->debug) echo "zip_entry=" . $zip_entry . "<br>"; $basename = basename(zip_entry_name($zip_entry)); $zipped_file = $this->upload_path . $basename; // other unrelated code } } Link to comment https://forums.phpfreaks.com/topic/250973-problems-with-zip_read/ Share on other sites More sharing options...
kicken Posted November 12, 2011 Share Posted November 12, 2011 while($zip_entry = zip_read($zip) && $i<500 ){ That does not do what you expect. The condition is run such as $zip_entry = (zip_read($zip) && $i<500), in other words $zip_entry will be assigned the result of the && condition, which is going to be either bool(true) or bool(false). You need to put parenthesis around the assignment to make sure it is run correctly. while(($zip_entry = zip_read($zip)) && $i<500 ){ Link to comment https://forums.phpfreaks.com/topic/250973-problems-with-zip_read/#findComment-1287591 Share on other sites More sharing options...
weezelds Posted November 15, 2011 Author Share Posted November 15, 2011 Arg, what an unrelated noob mistake. Thanks Link to comment https://forums.phpfreaks.com/topic/250973-problems-with-zip_read/#findComment-1288242 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.