Cnielsen4211 Posted October 19, 2010 Share Posted October 19, 2010 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. :'( Quote Link to comment https://forums.phpfreaks.com/topic/216233-zip-bzip2-and-gzip-going-nuts/ Share on other sites More sharing options...
trq Posted October 19, 2010 Share Posted October 19, 2010 Any help would be much apreciated. We need code and specific error messages relating to that code. There is nothing inherently wrong with the extensions themselves. Quote Link to comment https://forums.phpfreaks.com/topic/216233-zip-bzip2-and-gzip-going-nuts/#findComment-1123779 Share on other sites More sharing options...
Cnielsen4211 Posted October 20, 2010 Author Share Posted October 20, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/216233-zip-bzip2-and-gzip-going-nuts/#findComment-1124187 Share on other sites More sharing options...
BlueSkyIS Posted October 20, 2010 Share Posted October 20, 2010 are you sure the script directory is writable? have you tried an absolute path to the file instead of just the file name? Quote Link to comment https://forums.phpfreaks.com/topic/216233-zip-bzip2-and-gzip-going-nuts/#findComment-1124190 Share on other sites More sharing options...
Cnielsen4211 Posted October 20, 2010 Author Share Posted October 20, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/216233-zip-bzip2-and-gzip-going-nuts/#findComment-1124201 Share on other sites More sharing options...
Cnielsen4211 Posted October 20, 2010 Author Share Posted October 20, 2010 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 ) Quote Link to comment https://forums.phpfreaks.com/topic/216233-zip-bzip2-and-gzip-going-nuts/#findComment-1124210 Share on other sites More sharing options...
BlueSkyIS Posted October 20, 2010 Share Posted October 20, 2010 in case it helps, i use a separate zip class. i think i got it on phpclasses.org. i don't have a link, but the author is Rochak Chauhan. i have never had it fail or give me any problems. Quote Link to comment https://forums.phpfreaks.com/topic/216233-zip-bzip2-and-gzip-going-nuts/#findComment-1124214 Share on other sites More sharing options...
Cnielsen4211 Posted October 20, 2010 Author Share Posted October 20, 2010 Thanks BlueSkyIs, I'll check it out.. Ta Quote Link to comment https://forums.phpfreaks.com/topic/216233-zip-bzip2-and-gzip-going-nuts/#findComment-1124216 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.