Jump to content

[HELP] Zip function


Deorum

Recommended Posts

Hello, this is my first post, sorry for my english :D

 

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 :D

Link to comment
https://forums.phpfreaks.com/topic/137019-help-zip-function/
Share on other sites

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

 

 

Link to comment
https://forums.phpfreaks.com/topic/137019-help-zip-function/#findComment-715964
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.