Create Zip Archive from files in File set
Permalink
Hello folks,
I have a problem creating ZipArchive from files in File set. My goals is making a zip or folder that can be downloaded from link (same as with getDownloadURL()). What I have are files from set but then I don't know how to procced. At this point I really don't care if it is a regular folder or zip archive as long as files are in there and it can ve downloaded. If anyone can provide a code example or point me where to find the answear it will be awesome.
So far no solution I have found worked, like I wanted it to work.
Thanks for all of your help!
I have a problem creating ZipArchive from files in File set. My goals is making a zip or folder that can be downloaded from link (same as with getDownloadURL()). What I have are files from set but then I don't know how to procced. At this point I really don't care if it is a regular folder or zip archive as long as files are in there and it can ve downloaded. If anyone can provide a code example or point me where to find the answear it will be awesome.
So far no solution I have found worked, like I wanted it to work.
Thanks for all of your help!
Here's a project that creates a zip file and produces a download link for it:
https://github.com/gondwanasoft/simple-backup...
However, it doesn't know anything about file sets; nor does it produce a secure download link.
https://github.com/gondwanasoft/simple-backup...
However, it doesn't know anything about file sets; nor does it produce a secure download link.
First of all I figure it out, I just needed to switch folder where I wanted ZIP file to be created and now the code works.
But yeah my goal was something like that (Download Archive). I would link you the website but it's not in english so it wouldn't be of much use. The thing I wanted is on page there are files from File set listed in table and at the bottom I wanted to have a button/link which triggers some kind of zip+download event of the files displayed, so something similar to what download archive I guess. So nevertheless I fixed my bug could you show me your solution for how can I make Downloadable arhive of file set?
I'm posting my code below. I know it's not the best so I'm open to critics :) I want to make new folder to store zip in seperate folder but so far I'm still have permission trubles.
But yeah my goal was something like that (Download Archive). I would link you the website but it's not in english so it wouldn't be of much use. The thing I wanted is on page there are files from File set listed in table and at the bottom I wanted to have a button/link which triggers some kind of zip+download event of the files displayed, so something similar to what download archive I guess. So nevertheless I fixed my bug could you show me your solution for how can I make Downloadable arhive of file set?
I'm posting my code below. I know it's not the best so I'm open to critics :) I want to make new folder to store zip in seperate folder but so far I'm still have permission trubles.
<?php $dirName = "application/files/thumbnails/file_manager_detail/" . $c->getCollectionName(); if (!file_exists($dirName)) { mkdir($dirName, 0777); } $zip = new ZipArchive; $fileName = "application/files/thumbnails/file_manager_detail/" . $c->getCollectionName() . $c->getCollectionDateAdded() . ".zip"; $res = $zip->open($fileName, ZipArchive::CREATE); foreach($files as $f) { $zip->addFromString($f->getFilename(), $f->getFileContents()); } $zip->close(); $link = View::url("") . $fileName; ?> <td><a class="download-all" href="<?php echo $link; ?>"><?php echo t('Prenesi vse'); ?></a></td>
If not, what exactly are you trying to build?