There are a few csv files hosted on another website n i'm trying to retrieve them and package into a zip file to download. Zipping seems to work but the package is always empty. Any help is very much appreciated... This is in PHP by the way.
<?php
$zip = new ZipArchive();
$filename = "test114.zip";
$numParts = count($file_names);
if ($zip->open($filename, ZIPARCHIVE::CREATE)!==TRUE)
{
exit("cannot open <$filename>
");
}
$file="http://ichart.finance.yahoo.com/table.csv?s=YHOO&d=9&e=25&f=2012&g=d&a=0&b=3&c=2000&ignore=.csv";
$filedata = fopen ($file, "r");
$contents = fread($filedata, filesize($file));
$zip->addFile($filedata, "file1");
fclose($filedata);
$zip->close();
header('Content-Type: application/zip');
header("Content-Disposition: attachment; filename=\"".$filename."\".zip;");
header('Content-Length: ' . filesize($filename));
readfile($filename);
?>