php_zip not working

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
l9pt5
Forum Newbie
Posts: 17
Joined: Wed Apr 11, 2007 10:41 am

php_zip not working

Post by l9pt5 »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


I've the following code, but when I ran the script,  it doesn't seem to work.  Does anyone know why?  Please see output below.  Thanks,

ZipArchive Object (
	[status] => 0
	[statusSys] => 0
	[numFiles] => 0
	[filename] =>
	[comment] =>
)
object(ZipArchive)#1 (5) {
	["status"]=> int(0)
	["statusSys"]=> int(0)
	["numFiles"]=> int(0)
	["filename"]=> string(0) ""
	["comment"]=> string(0) ""
}
numFiles: 0
status: 0
statusSys: 0
filename: 
comment: 
numFile:0

Code: Select all

<?php

$za = new ZipArchive();

$za->open('test.zip');
print_r($za);
var_dump($za);
echo "numFiles: " . $za->numFiles . "\n";
echo "status: " . $za->status  . "\n";
echo "statusSys: " . $za->statusSys . "\n";
echo "filename: " . $za->filename . "\n";
echo "comment: " . $za->comment . "\n";

for ($i=0; $i<$za->numFiles;$i++) {
    echo "index: $i\n";
    print_r($za->statIndex($i));
}
echo "numFile:" . $za->numFiles . "\n";
?>

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Begby
Forum Regular
Posts: 575
Joined: Wed Dec 13, 2006 10:28 am

Post by Begby »

You should add in a test as follows

Code: Select all

if ($zip->open($filename)!==TRUE) {
    exit("cannot open <$filename>\n");
}
Post Reply