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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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