简体   繁体   中英

Image Rename Zip And Download codeigniter

Currently the zip is downloading and the images within the zip are off the names that are stored on the server i need to rename them I have 3 images on the server i need to download the images but before adding files to zip i need to rename them

public function downimages(){

$this->_check(); // session checker

$this->load->helper('download');

$this->load->library('zip');

$idm=$this->uri->segment(3);

$ab=$this->adminmod->downimg($idm);

$down=explode('-/,-', $ab[0]->director); //gets the directory stores in array

$fname=explode('-/,-', $ab[0]->file_oname); //gets the file names stores in array

foreach ($down as $key =>$value){

$name = $fname[$key]; // this is where the name is stored need to use this to rename $data = "./"($value);

$this->zip->read_file($data); //adds the images to zip archive }

$this->zip->download($idm.'.zip'); //downloads the zip fles

// redirect($_SERVER['HTTP_REFERER']); }

My server image names are like xfasf.jpg 2) sadweq.jpg 3)wqweq.jpg my actual file names are image1.jpg 2)blue.jpg 3)red.jpg whcih comes from $name

How do i go about this?

Solution Was Quite Easy

Solved IT at the $this->zip->read_file($data); I just put the $name like this $this->zip->read_file($data,$name); now the files get renamed before they get zipped and then downloaded

Solved IT at the $this->zip->read_file($data); i jsut put the $name like this $this->zip->read_file($data,$name); now the files get renamed before they get downloaded

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM