0

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.

2
  • 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.
    – DaveE
    Apr 17, 2010 at 16:24
  • 1
    I took the liberty of putting your comment in your question, as it makes for easier reading. You can however roll back or edit it to your liking, if you so wish. Apr 17, 2010 at 16:36

1 Answer 1

0

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

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

Reference for MV command

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.