<?php
class Unzip extends CI_Controller {
function __construct()
{
parent::__construct();
// load ci's Form and Url Helpers
$this->load->helper(array('form', 'url'));
}
function index()
{
$this->load->view('unzip/upload_form_view', array('error' => ' ' ));
}
function file_upload()
{
$config['upload_path'] = './upload/';
$config['allowed_types'] = 'zip';
$config['max_size'] = '';
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload())
{
$error = array('error' => $this->upload->display_errors());
$this->load->view('unzip/upload_form_view', $error);
}
else
{
$data = array('upload_data' => $this->upload->data());
$zip = new ZipArchive;
$file = $data['upload_data']['full_path'];
chmod($file,0777);
if ($zip->open($file) === TRUE) {
$zip->extractTo('./upload/');
$zip->close();
echo 'ok';
} else {
echo 'failed';
}
$this->load->view('unzip/upload_success_view');
}
}
}
?>
Next
« Prev Post
« Prev Post
Previous
Next Post »
Next Post »
Subscribe to:
Post Comments (Atom)