Jump to content

ZIP, BZip2 and GZip Going Nuts


Cnielsen4211

Recommended Posts

I have spent all day trying to get any of these functions to work...

 

I have downloaded heaps of expample and NONE! work..

 

In the case of Zip Archive the CREATE function will not produce a zip file archive to strat with.. Error message says it's created ok... but a search finds no such file.

 

GZip has the same problem.

 

Bzip2 at least creates a blank zip file (17bytes) but I can't add any files to the Bzip2.

 

I have tried on the localhost with dll's installed and on a comercial web server...

Nothing gets created...

 

I have read endless examples and documents on the web... None work..

 

Any help would be much apreciated.

 

:'(

 

 

Link to comment
Share on other sites

Hi... thanks for your response... This morning with clear head, I deleted all my previous attempts to get this working and started afresh.. Always better to put the broom through when you're stuck on a problem...

 

Here is my exact code... Pretty simple... but;

 

<?php

$zip = new ZipArchive(); 

if ($zip->open('MyZipTest.zip', ZipArchive::CREATE) !== TRUE) {

    die ("Could not open archive");

}

 

$zip->close();

?>

 

I do not get a file named 'MyZipTest.zip' on my server  folder and I get no "die" error message..  So I changed the code to

 

<?php

$zip = new ZipArchive();

$result = $zip->open('MyZipTest.zip', ZipArchive::CREATE);

 

if(!$result) {

echo "Zip not created<br>";

}

 

chmod(MyZipTest.zip,'0777');

 

$zip->close();

?>

 

and the error message I get comes from the chrmod which complains that MyZipTest.zip doesn't exist..

 

a check of the folder on the server shows that no zip file has been created.

 

I accept that the example code given on the PHP site should work and I must be doing something wrong, but what?

 

Kind Regards and hoping you can give me an  obvious "duh" type answer.

 

 

Carl Nielsen :shrug:

 

 

 

 

Link to comment
Share on other sites

Yes and Yes, BlueSkyIS, thanks for your response... the chmod of the folder is 755 and I can write (copy) other files to it... 

 

I may have stumbled onto the answer...  When I try to create just the archive file I get nothing, but when I also add a file to the archive it produced a file...

 

Maybe this is my problem.

 

Still experimenting...  I will let everyone know when I have finished experimenting with what works and what doesn't

 

Thanks again..

 

Cnielsen4211

 

 

 

 

Link to comment
Share on other sites

Hi all..

Thank you to those who responded in my time of need...

 

I think I have it sorted..

 

That is I think... I'm not sure if I trust this to be right... I'm beginning to think PHP doesn't like me...

 

Firstly, the zip (open :: create) statement will not actually create a file...  Silly me... there I was thinking that to create something you actually created something... Dumb assumption, as it turns out...  it is actually the CLOSE statement that writes the memory stream (I knew it was created somewhere) to the disk...

 

Secondly somewhere I read that the open( $zipName, ZIPARCHIVE::CREATE) is unreliable, (boy that's news) and that you should use

= $zip->open( $zipName, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE );  which I'm now using and it works...  I suppose the former also works but I'm not going backwards to check it out...

 

Third problem,,, I didn't actually get a result till I added text or a file to the archive.. I think the close statement saw me coming on that one.

and finally, one more mystery...  I used $Zip->status and got '0' as a result...  I then looked up the manual to find what the status values mean... Couldn't find any reference to a list of codes for status anywhere.. I hope '0' means "Ok"

 

Thanks again to those who pointed me in the right direction...

 

sorry for being a little sarcastic, but after three days, well you've all been there.

 

Kind Regards

CNielsen4211 (happy now  ;D)

 

 

 

 

 

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.