I try to create a code to download multi file at once on one click
I use this code to read the name of the file from my database and take many file name in one variable using a href to page name download
this is the code
$file_query=mysqli_query($conn,"select * from tbl_taskimage where db_taskid='$id'")or die(mysqli_error($conn));
$src = array();
if(mysqli_num_rows($file_query)>0){
while($r=mysqli_fetch_array($file_query)){
$src[]=$r['db_image'];}
echo"<a href='download.php?src=".implode('/',$src)."'><img src='../img/download.png'></a>";
}
To dowload this file I use this code in download page
$src=$_GET['src'];echo $src;
$ex=explode("/",$src);
for($i=0;$i<count($ex);$i++){
$file_url = '../uploads_images/'.$ex[$i];
header('Content-Type: application/octet-stream');
header("Content-Transfer-Encoding: Binary");
header("Content-disposition: attachment; filename=\"" . basename($file_url) . "\"");
readfile($file_url);
}
The problem is I can't download all the files. Only the first file will be downloaded. How can I solve this problem when I click the on a href all files will be downloaded?