Deorum Posted December 15, 2008 Share Posted December 15, 2008 Hello, this is my first post, sorry for my english I've a problem with PHP native ZIP function, i try to explicate... I upload archive and i will automatically extract all contents files, the problem is that if in the archiev there is a folder, i can not extract the file contents in the folder... My function extract all files, but not the files in the folders... For example, I've this archive: a.doc b.doc c.doc Folder Folder/d.doc Folder/e.doc When i upload my archive, the page extract a.doc, b.doc, c.doc and an empty folder (Folder), but no d.doc and e.doc. The problem is that i will extract ALL files in the archive, and not only files at level 0... My functions is: $numFiles = $zip->numFiles; for ($n=0; $n<$numFiles; $n++) { $file = $zip->statIndex($n); $zip->extractTo($uploaddir,$file["name"]); } The solution (I think) is: Read all files in the archive, if the file is a folder, open the folder and extract all files, else extract the file. Anyone can hel me please? I hope the problem is expianed... Thx and sorry for my english Quote Link to comment Share on other sites More sharing options...
Deorum Posted December 15, 2008 Author Share Posted December 15, 2008 Anyone can help me please? Quote Link to comment Share on other sites More sharing options...
Mad Mick Posted December 15, 2008 Share Posted December 15, 2008 Have you tried skipping the second parameter in extractTo? So its just $zip->extractTo($uploaddir); Quote Link to comment Share on other sites More sharing options...
T Horton Posted December 15, 2008 Share Posted December 15, 2008 Hi I have been doing a bit of searching on the web for you and found the following address: http://uk.php.net/manual/en/function.zip-open.php On there is some code that extracts files from folders and subfolders in zip files by someone called "xsign dot dll at clansuite dot com". Hopefully this might point you in the right direction. Best Regards Tom Quote Link to comment 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.