ddgrim Posted February 28, 2010 Share Posted February 28, 2010 Hi, I am trying to create a page where passing an ID of a file will allow multiple file downloads. but only the first file is being downloaded, for example "file.php?code=1,2,3,4" will only download file 1 Any help would be much appreciated. <?php $ItemID = $_GET['code']; $FilesID = explode(",", $ItemID); include('db.php'); foreach($FilesID as $ItemID){ $sql = "SELECT COUNT(*) FROM items WHERE ItemID = ".$ItemID.";"; $result = mysql_result(mysql_query($sql), 0); if($result == 1){ $sql = "SELECT ItemFileType, ItemName, Path, FileSize FROM items WHERE ItemID = ".$ItemID.";"; $result = mysql_query($sql); $FileType = mysql_result($result, 0, 'ItemFileType'); $ItemName = mysql_result($result, 0, 'ItemName'); $Location = mysql_result($result, 0, 'Path'); $FileSize = mysql_result($result, 0, 'FileSize'); header("Content-Description: File Transfer", true); header('Content-Disposition:attachment; filename='.$ItemName.'.'.$FileType.'', true); header('Content-Length: '.$FileSize.'', true); readfile($Location.'/'.$ItemID.'.'.$FileType); } } ?> Link to comment https://forums.phpfreaks.com/topic/193646-multiple-file-download/ Share on other sites More sharing options...
trq Posted February 28, 2010 Share Posted February 28, 2010 Can't be done. Once your headers have been sent, no more content can follow. Link to comment https://forums.phpfreaks.com/topic/193646-multiple-file-download/#findComment-1019334 Share on other sites More sharing options...
ddgrim Posted February 28, 2010 Author Share Posted February 28, 2010 damm, thanks for the speedy reply Link to comment https://forums.phpfreaks.com/topic/193646-multiple-file-download/#findComment-1019336 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.