Jump to content

Cnielsen4211

New Members
  • Posts

    7
  • Joined

  • Last visited

    Never

Everything posted by Cnielsen4211

  1. More dramas... I have this code : $dir = $zipdir.'/unpack'; // which is a valid directory chmod($dir,0775); $zip = new ZipArchive; if ($zip->open($zipdir.'/'.$zipname) === TRUE) { $zip->extractTo($dir); $zip->close(); And it sort of works... I get the unpacked files placed in $dir no problems.. But it produces this error. Warning: ZipArchive::extractTo(tempdir/unpack/..) [ziparchive.extractto]: failed to open stream: Is a directory ???? It did open the directory and it did extract the files, so why is it giving me this error message? Anyone ???
  2. Just when I finally figured out how to create a Zip file and I thought the rest would be easy… This problem comes along… When I attempt to extract files from a Zip with the following code; $uzipfolder = 'tempdir'; $filename = 'MyZipTest.zip'; $zipfolder = 'tempdir/'; $zip = new ZipArchive; $zipfile = $zipfolder.$filename; echo 'Zip file is '.$zipfile.'<br>'; //correct echo 'The unZip folder is '.$uzipfolder.'<br>'; // correct chmod($uzipfolder,0777); // the folder has permissions 0777 $res = $zip->open($zipfile); if ($res === TRUE) { $zip->extractTo($uzipfolder); $zip->close(); //unlink($zipfile); // I removed this line to preserve my zip file echo 'Ok<br>'; } else { echo 'failed<br>'; } The Extracted files are created and in the correct “tempdir” folder, but I get error messages saying “Warning: ZipArchive::extractTo(tempdir/..) [ziparchive.extractto]: failed to open stream: Is a directory” The files are extracted and are in the tempdir directory so if it wasn’t for the error message all would be ok. If I change the line “$zip->extractTo($uzipfolder);” to $zip->extractTo($uzipfolder,””); as it should be I don’t get any error message, and I don’t get any extracted files… Can someone tell me what I’m doing wrong, please… Kind Regards CNielsen4211
  3. 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 )
  4. 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
  5. 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
  6. 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. :'(
×
×
  • 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.