开发者

Remove excess empty directories in uploaded zip file

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.


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

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

Reference for MV command

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜