function download($album) { mp3act_connect(); $query = "SELECT mp3act_songs.filename,\n\tmp3act_artists.artist_name,\n\tmp3act_albums.album_name \n\tFROM mp3act_songs,mp3act_artists,mp3act_albums \n\tWHERE mp3act_songs.album_id={$album} \n\tAND mp3act_songs.album_id=mp3act_albums.album_id \n\tAND mp3act_songs.artist_id=mp3act_artists.artist_id LIMIT 1"; $result = mysql_query($query); $row = mysql_fetch_array($result); $dir = dirname($row['filename']); $test = new zip_file("/tmp/album_{$album}.zip"); $test->set_options(array('inmemory' => 0, 'storepaths' => 0, 'level' => 0, 'method' => 0, 'prepend' => "{$row['artist_name']} - {$row['album_name']}")); $test->add_files($dir); $test->store_files($dir); $test->create_archive(); header("Content-type:application/zip"); $header = "Content-disposition: attachment; filename=\""; $header .= "album_{$album}.zip"; $header .= "\""; header($header); header("Content-length: " . filesize("/tmp/album_{$album}.zip")); header("Content-transfer-encoding: binary"); header("Pragma: no-cache"); header("Expires: 0"); $chunksize = 1 * (1024 * 1024); // how many bytes per chunk $buffer = ''; $handle = fopen("/tmp/album_{$album}.zip", 'rb'); if ($handle === false) { return false; } while (!feof($handle)) { $buffer = fread($handle, $chunksize); print $buffer; } fclose($handle); //readfile("/tmp/album_$album.zip"); unlink("/tmp/album_{$album}.zip"); //$test->download_file(); }