I'm changing some things around on my webapp and one of the major changes is assets are now stored in S3 (via filepicker.io) rather than locally. Here is some code I have to generate a zip file from an array of files
//example values
//loc could be uploads/1/7878837474test.jpg
//name coule be test.jpg
$downloadarray = array();
while($row = mysql_fetch_array($res)){
$downloadarray[] = array($row['loc'], $row['name']);
}
$zipname = rand(0,9999) . 'download.zip';
$zip = new ZipArchive;
$zip->open($zipname, ZipArchive::CREATE);
foreach ($downloadarray as $file) {
$zip->addFile($file['0'], $file['1']);
}
$zip->close();
header('Content-Type: application/zip');
header('Content-disposition: attachment; filename=' . $zipname);
header('Content-Length: ' . filesize($zipname));
readfile($zipname);
unlink($zipname);
However now the $row['loc']
variable is going to be a remote URL. What is the best way to get external files set up? If possible I don't want to have to download the file onto the server. Just to let you know, if the adding seems to have been done in a strange way it is because originally uploads were stored in 5 different folders and I wanted to reset the file tree so they were all in the root of the zip. However this should no longer be necessary