Hybride Posted May 31, 2009 Share Posted May 31, 2009 Hey everyone, I've been trying to figure out how to unzip a file in a different folder that's stored in an array. I got it to extract properly (get the whole zip name and whatnot), and the system("unzip -qq") works correctly, but only in the same folder. $arr_theme_data['file_url'] = "/link/to/folder/"; $arr_theme_data['file_file'] = "AlgaeWater.zip"; extract($arr_theme_data, EXTR_PREFIX_SAME, "wddx"); echo $arr_theme_data['file_file']; //prints out AlgaeWater.zip, as it should system("unzip -qq "$arr_theme_data['file_url'].$arr_theme_data['file_file']);//this doesn't Sorry about the ugliness. Anyone have an idea how to unzip the file? Quote Link to comment https://forums.phpfreaks.com/topic/160410-solved-unzip-file-from-array-in-different-folder/ Share on other sites More sharing options...
Hybride Posted June 1, 2009 Author Share Posted June 1, 2009 Ok, figured it out. Found a different script, and messed with it, turns out the extract() was what I needed, and make sure to have absolute paths in your code. (It was a 3D array btw, that's what was giving me the hard time.) extract($arr_theme_data['file_file'], EXTR_PREFIX_SAME, "wddx"); // start up the ZipArchive to extract $zip = new ZipArchive; $res = $zip->open($filePath . $name); if ($res === TRUE) { // echo "Zip Success!"; //creates the folder in the demo area and extracts files there. $zip->extractTo($demoPath); $zip->close(); } else { // http://php.oregonstate.edu/manual/en/function.ziparchive-open.php // to see what kind of error, if any, shows up. echo 'ZIP FAILED, code:' . $res; } in case someone wants to know what I did. Quote Link to comment https://forums.phpfreaks.com/topic/160410-solved-unzip-file-from-array-in-different-folder/#findComment-846574 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.