PHP中的提取路径问题

I have a model function in CodeIgniter which first uploads a zip, rar file to server location and then extracts it.

But before that I need to specify the file structure

root folder
--- application
    --admin
        --controllers
        --models
        --views
           --newsletter
--- system
---
---
---

Here's my model function

function add_newsletter()
{
    if($_FILES['unextract']['name']=="")
                {
                  return "Successfully added";
                }
             else if($_FILES['unextract']['name']!=''&& 
                     ($_FILES['unextract']['type']=='application/zip'
                     || $_FILES['unextract']['type']=='application/x-zip' 
                     || $_FILES['unextract']['type']=='application/octet-stream'
                     || $_FILES['unextract']['type']=='application/x-zip-compressed'
                     || $_FILES['unextract']['type']=='application/x-rar-compressed'
                     || $_FILES['unextract']['type']=='application/x-rar' 
                     || $_FILES['unextract']['type']=='application/rar'))
                {
                        if(!file_exists('./application/admin/views/newsletter/'))
                              mkdir('./application/admin/views/newsletter/');
                        $file_name=md5(uniqid(rand())).$_FILES['unextract']['name']; //  name of the file being changed with encryption, ex cd102453xz_ersnewsletter-1.zip
                        $image= 'application/admin/views/newsletter/'.$file_name;
                        $unxt="./".$image;
                        move_uploaded_file($_FILES['unextract']['tmp_name'],$unxt); //$_FILES['unextract']['tmp_name'] is equal to newsletter-1.zip
                        $zip = new ZipArchive;
                        if ($zip->open($unxt) === TRUE) 
                            {
                                $folder=explode(".",$image);
                                $zip->extractTo('./'.$folder[0]); // $folder[0] stands for application/admin/views/newsletter/cd102453xz_ersnewsletter-1
                                $zip->close();
                                $data['msg']="Uploaded To database";
                                $title=$file_name;
                                $timestamp=time();
                                $data = array(
                                    'newsletter_title' => $title,
                                    'newsletter_timestamp' => $timestamp,
                                    'newsletter_date'=>date('d/m/Y')
                                );
                                $msg=$this->insert('td_newsletter',$data,$timestamp);
                                if($msg=="done")
                                    return "NewsLetter Added To System";
                            } 
                        else 
                            {
                                return "NewsLetter Not Added To System";
                            }
                }
}

The issue is that the files of newsletter-1.zip is extracted into the location

application/admin/views/newsletter/cd102453xz_ersnewsletter-1/newsletter-1/

while it should be extracted to

application/admin/views/newsletter/cd102453xz_ersnewsletter-1/

Right now the file-structure is like this:

--application
  --views
     --newsletter
       --cd102453xz_ersnewsletter-1
         --newsletter-1
           --screenshot.png
           --index.html.php
           --images/

while the desired file-structure I want is

--application
      --views
         --newsletter
           --cd102453xz_ersnewsletter-1
              --screenshot.png
              --index.html.php
              --images/

When you are creating the newsletter.zip you are zipping the folder newsletter so your zip file will look like this

newsletter.zip:
 - newsletter :
   - file1
   - file2
   - file3

try to open the newsletter folder, select the files inside the folder and then zip them, your structure will be like this:

newsletter.zip:
 - file1
 - file2
 - file3