Skip to content

Instantly share code, notes, and snippets.

@ayies128
Last active January 16, 2017 09:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ayies128/4b34c4566c8a9b4b6099a80a26cd2cd3 to your computer and use it in GitHub Desktop.
Save ayies128/4b34c4566c8a9b4b6099a80a26cd2cd3 to your computer and use it in GitHub Desktop.
zip_folder
public function zip_folder
{
$this->load->library('zip');
$img_folder_list = [
'folder1' => ['http://img1.jpg', 'http://img2.jpg', 'http://img3.jpg'],
'folder2' => ['http://img4.jpg', 'http://img5.jpg', 'http://img6.jpg'],
'folder3' => ['http://img7.jpg', 'http://img8.jpg', 'http://img9.jpg'],
];
foreach ($img_url_list as $folder_name => $img_url_list) {
$this->zip->add_dir($pid);
foreach ($img_url_list as $img_url) {
$split_url = explode('/', $img_url);
$this->zip->add_data($pid . '/' . $split_url[count($split_url) - 1], file_get_contents($img_url));
}
}
$this->zip->archive('img_list.zip');
$this->zip->download('img_list.zip');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment