Welcome Guest, Not a member yet? Register   Sign In
Zip files in loop and rename
#1

[eluser]behnampmdg3[/eluser]
Hi;

How can I rename each file when I add them to zip? In other words this $this->zip->read_file($path); I need to change to something like $this->zip->read_file($path, $new_name);

Can anyone help?

Thanks
Code:
class Download_zip_qr extends CI_Controller {
  
public function download($order_id)
  {
   $this->load->helper('download');
   $this->load->library('zip');
   $this->load->model('model_auth');
   $results['card_details'] = $this->model_auth->card_details_order($order_id);
   foreach($results['card_details'] as $row)
    {
    
     $path = 'QR_codes/'.$row->shortUrl.".png";
     $this->zip->read_file($path);
    }
   $this->zip->download('QR_order_'.$order_id.'.zip');
  }
}
#2

[eluser]CroNiX[/eluser]
Looks like you can just use $this->zip->archive('/path/to/save/file.zip');
#3

[eluser]behnampmdg3[/eluser]
[quote author="CroNiX" date="1393998694"]Looks like you can just use $this->zip->archive('/path/to/save/file.zip');[/quote]Hi Cronix;

How would you achieve what I want to achieve then? You know I want every file to have a specific name.

Thanks
#4

[eluser]CroNiX[/eluser]
In my example, you would just change "file.zip" to whatever you want to save it as. I just took it from the docs, so check there or try testing it. I haven't used this myself.
#5

[eluser]behnampmdg3[/eluser]
[quote author="CroNiX" date="1394069131"]In my example, you would just change "file.zip" to whatever you want to save it as. I just took it from the docs, so check there or try testing it. I haven't used this myself.[/quote]Hey man;

I need to rename each individually added file name Smile

Makes sense?
#6

[eluser]CroNiX[/eluser]
Yes, so try repeating it for each name. Beyond that, I don't know. I don't use this so you'll have to play with it.
#7

[eluser]InsiteFX[/eluser]
If he wants to rename each file he would need to read each one in a for loop and rename them.




Theme © iAndrew 2016 - Forum software by © MyBB