Hi,
I am experiencing a problem which is preventing me from finishing my current development project.
I need to zip a number of mp3 files located at various filepaths and enable the user to download the zip file to their system. It appears that the best way of doing this is by using php’s ZipArchive class. Whilst working running the script on my localhost I accomplished this quite easily with the following code:
$archive = 'my_archive_' . time() . '.zip';
$zip = new ZipArchive();
$zip->open($archive, ZIPARCHIVE::CREATE);
foreach ($calls as $conversation){
$url = '\\\\\\\\path\\\ o the\\\\file.mp3';
$zip->addFile($url, $conversation['MessageId'] . '.mp3');
}
$zip->close();
// Set headers
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Disposition: attachment; filename=$archive");
header("Content-Type: application/zip");
header("Content-Transfer-Encoding: binary");
readfile($archive);
The problem is that when I run the same script on the web server, the zip archive is downloaded but the files are empty. I realise its going to be difficult for anyone to help without knowing the setup I’m using but I hoped somebody might be able to suggest why this might be? If it makes any difference the web server is IIS.
Many thanks