Reputation: 8916
I have a form which sends 2 images to my controller
<form action="generate" method="post" accept-charset="utf-8" enctype="multipart/form-data">
<input type="file" name="image1" size="20" />
<input type="file" name="image2" size="20" />
<input type="submit" class="btn btn-success" value="upload" />
</form>
Now in my controller i want to compress image1
and image2
to zip format and save it in a folder.
I also see this documentation but i don't know how to add 2 images in one file .
Any ideas?Thanks in advance.
Upvotes: 0
Views: 2131
Reputation: 12826
Codeigniter has a library meant for helping with zip utilities:
You can load it like this:
$this->load->library('zip');
Then the class object can be accessed as:
$this->zip
For zipping a file, you can do this:
$path1 = '/path/to/photo1.jpg';
$path2 = '/path/to/photo2.jpg';
$this->zip->read_file($path1);
$this->zip->read_file($path2);
$this->zip->archive('/path/to/folder/my_images.zip');
You can read more at CodeIgniter's Zip Library Documentation
Upvotes: 1