Welcome Guest, Not a member yet? Register   Sign In
How to zip ( compress ) or unzip a file
#1

[eluser]RaiNnTeaRs[/eluser]
Hi all, I've read the methods for uploading and zipping the files, but it doesnt work.
The uploading code is working, but I still cant zip( compress) the files.
the idea is to zip the file once , I've upload it.
This is my last code , thx

<html>
<head>
<title>Upload SUCCESS</title>
</head>
<body>

<h3>Your file was successfully uploaded!</h3>

<ul>
&lt;?php foreach($upload_data as $item => $value):?&gt;
<li>&lt;?=$item;?&gt;: &lt;?=$value;?&gt;</li>
&lt;?php endforeach; ?&gt;
</ul>
&lt;?php
$descrip = $_POST['descrip'];
$fn=element('file_name', $upload_data);

$path='./storage/'.$fn;
$this->zip->clear_data();
$this->zip->read_file($path,TRUE);
//$this->zip->archive($path);
//echo "AHOOOOOOOOY : ".element('file_name',$item)."<br />";
$this->db->set('filename',$fn);
$this->db->set('description',$descrip);
$this->db->set('sender',$this->session->userdata('username'));

$this->db->insert('tabel_storage');

?&gt;
<p>&lt;?=anchor('dojang/uploading', 'Upload Another File!'); ?&gt;</p>
<p>&lt;?=anchor('dojang/news', 'Back to Home'); ?&gt;</p>
&lt;/body&gt;
&lt;/html&gt;
#2

[eluser]RaiNnTeaRs[/eluser]
can someone help ? thanks
#3

[eluser]gtech[/eluser]
dont know if it helps.. but this is my code to compress and decompress.. I coded it a while a go so its untested on 1.6.1
Code:
function build_zipa($dataid)
  {
    $file = $this->filebuild->build_mydata($dataid,'none','',0);
    $output = var_export($file,true);
    $encrypted_string = $this->encrypt->encode($output,"tree");
    $this->zip->add_data('filedata.svy',$encrypted_string);
    // I made a function up to create a time stamp
    $created = $this->survey_cookie->make_date('file');
    $this->zip->archive('./downloads/filedata'.$dataid.'-'.$created.'.zip');
    return $created;
  }

  function retrieve_zipa($dataid,$created)
  {
    $path = 'C:\\xampp\\htdocs\\testapp\\codeigniter\\downloads\\filedata'.$dataid.'-'.$created.'.zip';

    $zip = zip_open($path);
    if ($zip) {
      while ($zip_entry = zip_read($zip)) {
        if (zip_entry_open($zip, $zip_entry, "r")) {
          $buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
          zip_entry_close($zip_entry);
        }
      }
      zip_close($zip);
    }
    $plaintext_string = $this->encrypt->decode($buf,"tree");
    eval('$newarray = ' . $plaintext_string . ';');
    return $newarray;

  }
#4

[eluser]RaiNnTeaRs[/eluser]
Thanks bro ^^.I'll try it Big Grin




Theme © iAndrew 2016 - Forum software by © MyBB