webhead2 Posted October 22, 2008 Share Posted October 22, 2008 I am testing the following code: Notice I am try three techniques to extract the file: require_once("zip.lib.php"); require_once("unzip.lib.php"); $file = "incoming_data/marketplace_feed_v1.xml.zip"; // first attempt, no work system("unzip $file -d /incoming_data/"); // second attempt, dopes not work either exec($file); // third attept, works but encoded output $zip = new SimpleUnzip(); $filename = $file; $entries = $zip->ReadFile($filename); foreach ($entries as $entry){ $fh = fopen($entry->Name, 'w', false); fwrite($fh,$entry->Data); fclose($fh); } The first two attemot out put nothing, the third (SimpleUnzip) unzips the files, but the contents are encoded like this: ̽ÛrãØÑ.x燎lu»»L¢ˆm{Àƒ$vñÔ$UêòŽ; ’àš Any help is appreciated. I've check the integrity of marketplace_feed_v1.xml.zip. I've downloaded it and it unpacks nicely. I'm running, Linux, Apache, VPS. I took my code straight from the PHP manual. Thanks for your help! Quote Link to comment https://forums.phpfreaks.com/topic/129607-trouble-using-unziplibphp-to-extract-zip-archives/ Share on other sites More sharing options...
trq Posted October 22, 2008 Share Posted October 22, 2008 Straight from the php manual? Neither zip.lib.php or unzip.lib.php are part of php, but are third party scripts. Quote Link to comment https://forums.phpfreaks.com/topic/129607-trouble-using-unziplibphp-to-extract-zip-archives/#findComment-671909 Share on other sites More sharing options...
webhead2 Posted October 22, 2008 Author Share Posted October 22, 2008 http://www.php.net/manual/en/ref.zip.php Let's not go off on a tangent here. I'm dying slowly. Quote Link to comment https://forums.phpfreaks.com/topic/129607-trouble-using-unziplibphp-to-extract-zip-archives/#findComment-671939 Share on other sites More sharing options...
rhodesa Posted October 22, 2008 Share Posted October 22, 2008 are you just trying to extract all the files? http://www.php.net/manual/en/function.ziparchive-extractto.php Quote Link to comment https://forums.phpfreaks.com/topic/129607-trouble-using-unziplibphp-to-extract-zip-archives/#findComment-671965 Share on other sites More sharing options...
webhead2 Posted October 22, 2008 Author Share Posted October 22, 2008 Yes, i am trying to extract all of the files, that's it. I tried this: $file = "incoming_data/marketplace_feed_v1.xml.zip"; $zip = new ZipArchive; if ($zip->open('incoming_data/marketplace_feed_v1.xml.zip') === TRUE) { $zip->extractTo('/incoming_data/'); $zip->close(); echo 'ok'; } else { echo 'failed'; } I GET NOTHING, no message, no files Quote Link to comment https://forums.phpfreaks.com/topic/129607-trouble-using-unziplibphp-to-extract-zip-archives/#findComment-671993 Share on other sites More sharing options...
rhodesa Posted October 22, 2008 Share Posted October 22, 2008 are you sure....notice you use '/incoming_data/' and not 'incoming_data/'. that leading slash will cause it to create a folder in your root directory Quote Link to comment https://forums.phpfreaks.com/topic/129607-trouble-using-unziplibphp-to-extract-zip-archives/#findComment-672010 Share on other sites More sharing options...
webhead2 Posted October 22, 2008 Author Share Posted October 22, 2008 Thanks for your help. system("unzip $file -d incoming_data/"); This works. It was dumping the files into root. I thought I had tried both, but you know how it goes when you get waist deep in code. Thanks again for the extra pair of eyeballs. I wonder, is there a way to test if this function is enabled on the server? Will most servers have this functionality installed by default? I ask because I am making an installer. system("unzip $file -d incoming_data/"); Quote Link to comment https://forums.phpfreaks.com/topic/129607-trouble-using-unziplibphp-to-extract-zip-archives/#findComment-672029 Share on other sites More sharing options...
trq Posted October 23, 2008 Share Posted October 23, 2008 If your making an installing I would suggest using tar.gz as your compression. tar is pretty well guaranteed to be installed on all Linux's. unzip, most likely isn't. Quote Link to comment https://forums.phpfreaks.com/topic/129607-trouble-using-unziplibphp-to-extract-zip-archives/#findComment-672347 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.