[eluser]thematrixuum[/eluser]
Here's my view :
Code:
<div class="content">
<h1><?= $title; ?></h1>
<?php echo form_open_multipart('asset/uploadify');?>
<div class="data">
<div class="step1">
<span class="head-step1">Step 2 : Upload your zip file : </span>
<table>
<tr>
<td>File</td>
<td>
<div id="upload_form"><?php echo form_upload(array('name' => 'Filedata', 'id' => 'upload'));?><a href="[removed]$('#upload').uploadifyUpload();">Upload</a></div>
<div id="target" display="hidden"></div>
</td>
</tr>
</table>
</div>
</div>
<?php echo form_close(); ?>
<br />
<?= $link_back; ?>
</div>
Here's my controller :
Code:
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>]');
//print_r(base_url().'assets/upload/'.$data['file_name']);
//print_r($data);
if($this->unzip($file_path, $file_name)) {
print_r($file_path);
print_r('<br>'.$path_test);
print_r('<br>Success');
}
else {
print_r('Fail');
print_r('<br>'.$path_test);
print_r('<br>Path : '.base_url().'assets/upload/'.$data['file_name']);
}
}
and here's my model :
Code:
function unzip($file_path, $file_name) {
$newfolder = $this->RemoveExtension($file_name);
$zip = new ZipArchive;
if ($zip->open($file_path) === TRUE) {
$zip->extractTo(base_url().'assets/upload/');
$zip->close();
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..