Last active
January 16, 2017 09:43
-
-
Save ayies128/4b34c4566c8a9b4b6099a80a26cd2cd3 to your computer and use it in GitHub Desktop.
zip_folder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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