CodeIgniter Forums
Zip files from URL - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Zip files from URL (/showthread.php?tid=1417)



Zip files from URL - behnampmdg3 - 03-08-2015

Hi;

How can I zip a few files from url?

This doesn't seem to be the right approach:

PHP Code:
$data = array(
'https://s3.amazonaws.com/files/templates/ai/Tactify+Card+Template+NFC+-+QR.ai' => 'NFC-QR-ai',
'https://s3.amazonaws.com/files/templates/ai/Tactify+Card+Template+NFC.ai' => 'NGF-ai');

$this->zip->add_data($data);
$this->zip->download('templates.zip'); 



RE: Zip files from URL - behnampmdg3 - 03-09-2015

Anyone?

Is there something wrong with CI's zip library?

I read in a few posts that this is broken Sad


RE: Zip files from URL - silentium - 03-10-2015

I think you have misunderstood how the add_data function works when using an array. You are trying to use the file key as path, which is incorrect.
  1. The parameters are ordered as file => contents, first parameters being the file name you want to have in the zip file, and the second parameter being the content to put into that file.

  2. For the content, the add_data function do not support reading a file. You either have to use the read_file function or read the file yourself by using file_get_contents()

  3. As far as I'm aware, the zip library do not support reading external urls. The paths has to be to a file on your server. If your server support reading external urls, you should be able to use file_get_contents()

http://www.codeigniter.com/userguide3/libraries/zip.html