Welcome Guest, Not a member yet? Register   Sign In
extract uploaded zip files

Here's my view :
<div class="content">
    <h1>&lt;?= $title; ?&gt;</h1>
    &lt;?php echo form_open_multipart('asset/uploadify');?&gt;
        <div class="data">
          <div class="step1">
            <span class="head-step1">Step 2 : Upload your zip file : </span>
             <div id="upload_form">&lt;?php echo form_upload(array('name' => 'Filedata', 'id' => 'upload'));?&gt;<a href="[removed]$('#upload').uploadifyUpload();">Upload</a></div>
             <div id="target" display="hidden"></div>
    &lt;?php echo form_close(); ?&gt;
    <br />
    &lt;?= $link_back; ?&gt;

Here's my controller :
function uploadify() {
                $data['response'] = json_decode($this->input->post('filearray'));

                //Access data using php json object
                $data['file_name'] = $data['response']->file_name;
                //$data['file_path'] = $data['response']->file_path;
                //$data['file_size'] = $data['response']->file_size;
                //$data['file_type'] = $data['response']->file_type;
                //$data['file_ext'] = $data['response']->file_ext;
               // print_r($data['file_name']);
                $file_path = base_url().'assets/upload/'.$data['file_name'];
                $file_name = $data['file_name'];
                $path_test = base_url().'assets/upload/';
                // print_r($data['file_ext']);
                //print_r($data['file_name'].'[<span id="delete-file" style="cursor:pointer;color:#cacaca;"> Delete </span>]');
                if($this->unzip($file_path, $file_name)) {
                else {
                    print_r('<br>Path : '.base_url().'assets/upload/'.$data['file_name']);

and here's my model :
function unzip($file_path, $file_name) {
        $newfolder = $this->RemoveExtension($file_name);
        $zip = new ZipArchive;
        if ($zip->open($file_path) === TRUE) {
            unlink($file_path); #deletes the zip file. We no longer need it.
    function RemoveExtension($strName)
         $ext = strrchr($strName, '.');
         if($ext !== false)
             $strName = substr($strName, 0, -strlen($ext));
         return $strName;

I don't know waht is the problem but it seems that I cannot extract the zip file uploaded into the server.. Can anybody help me? Thanks a mil..

look at this line of code


To extract zip file you need physical path location

where base_url() is not a actual physical path

thanks for the reply.

how can i retrieve the physical path of the file?

are you running in the local windows ?

for example "C:\xampp\htdocs\mydir";

if yes then


yes current development is in windows. but the server is in unix environment. when the server is live, what should i change? thanks for the reply.

if you are in live server

for example "http://www.example.com" and you wanna upload in ‘/assets/upload/’

which means http://www.example.com/assets/upload/

then just use


cool.. thanks for the reply..

Theme © iAndrew 2016 - Forum software by © MyBB