Jump to content

[SOLVED] zip


jagguy

Recommended Posts

I have php4.4.4 and have enabled zip on php.ini. On phpinfo() is says zip is enabled on my winxp pc.

I can't get any zip programs to work as whenever i use the word zip_open I get an error. I have asked this before everywhere and no one seems to have any idea .

Does zip work at all in php4.4.4 or is there a bug. Should I use php5 and zip instead?
Link to comment
https://forums.phpfreaks.com/topic/32121-solved-zip/
Share on other sites

[quote author=thorpe link=topic=120211.msg492885#msg492885 date=1167351996]
What is the error your getting?
[/quote]

Warning: zip_open() Cannot open zip archive ./test1.zip in C:\www\php\test\zip1.php on line 5

test1.zip works and was created with winzip, and is in the same directory. Also I tried in different dir and using just 'test1.zip' and as many combinations as possible. NO zip commands are recognized as it doesn't know what zip is, even though it is enabled in php.ini and phpinfo().
Link to comment
https://forums.phpfreaks.com/topic/32121-solved-zip/#findComment-149115
Share on other sites

Make sure theyre in the same directory and run

[code=php:0]
$file = "test1.zip";
if(file_exists($file)) {
if(function_exists('zip_open') {
if(zip_open($file)) {
echo "it opened!";
}
else {
echo "darn, didnt open";
}
}
else {
die("problem with the zip_open function");
}
}
else {
die("the file doesnt exists");
}
[/code]

If that returns the "darn it didnt open" thing or give you the error from earlier try an absolute path such as C:\test1.zip or C:\\test1.zip
Link to comment
https://forums.phpfreaks.com/topic/32121-solved-zip/#findComment-149122
Share on other sites

You know, I had a hell of a time trying to get the zip functions working on a winxp box too.  I never found a solution I was satisfied with but I did find a few things that may help you give up sooner.

You need the absolute path, not a relative one.
If you are attempting to zip files, well...it sucks.  One of the issues I had to deal with was my path was something like C:\Apache2\htdocs\whatever\temp\tempfile1.zip and when I attempted to zip that file it worked.  When I unzipped that file I got an Apache2 folder, htdocs folder, whatever folder, temp folder and tempfile1.zip inside of it. 

Basically what I'm getting at is you are going to spend a while trying to get it to work on a winxp box.  *nix is the only way to go with this I'm sad to say.
Link to comment
https://forums.phpfreaks.com/topic/32121-solved-zip/#findComment-149161
Share on other sites

Ok I can get ot to read zip files now with an absolute path on winxp.

I can't get it to extract the files from the zip and save on a dir after uploading.

Basically the '$zip = new ZipArchive()' won't work. It can't understand what

new ZipArchive() is at all or any ZipArchive object commands.

<?php


$zip = new ZipArchive(); //Fatal error: Cannot instantiate non-existent class: ziparchive

if ($zip->open('c:/www/php/test/test2.zip') === TRUE) {
  $zip->extractTo('c:/www/php/test/test/');
  $zip->close();
  echo 'ok';
} else {
  echo 'failed';
}

?>


Link to comment
https://forums.phpfreaks.com/topic/32121-solved-zip/#findComment-149214
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.