tags:

views:

40

answers:

1

Hello,

I am trying to remove excess directories from an uploaded zip file.

For example I would like to transform :

/folder1/folder2/folder3/ [Files are in this folder]

to

/folder1/[files are in this folder]

Any help would be appreciated, Thanks.

Hello,

I am trying to remove excess directories from an uploaded zip file.

For example I would like to transform :

/folder1/folder2/folder3/ [Files are in this folder]

to

/folder1/[files are in this folder]

Any help would be appreciated, Thanks.

edit:

what I have so far is

function zip_extract($file, $extractPath)
{
  $zip = new ZipArchive;
  $res = $zip->open($file);
  if ($res === TRUE)
  {
    $zip->extractTo($extractPath); 
    $zip->close();
    return TRUE;
  }
  else
  {
     return FALSE;
  }
} 

I'm not sure how to go about removing the unwanted directories though.

A: 

Hi,

If you are using a linux you can call from PHP;

<?php
exec('mv /folder1/folder2/folder3/ /folder1');
?>

Reference for MV command

Adnan