I'm trying to download files that are checked by a user but my problem is that it only downloads one file. I'm using Mysql store the file names its filetype. Where as actual files are stored in folder on the server.
Any help would be greatly appreciated.
My code looks like this:
<form>
<input type="checkbox" name="up_share[]" value="<?php echo $id ; ?>
<input type="submit" name="submit" value="download">
</form>
<?php
$i_path = "./images"; //folder for image files
$t_path = "./text"; //folder for text files
if($submit == "download") {
$fd_array = count($up_share);
for($i=0; $i<$fd_array; $i++) {
$result_f = mysql_query("SELECT type, f_link FROM info WHERE id='$up_share[$i]'");
$number_f = mysql_num_rows($result_f);
if($number_f) {
$myrow = mysql_fetch_array($result_f);
$f_link = $myrow["f_link"];
$type = $myrow["type"];
list($fa_name,$exte) = explode(".",$f_link);
$fd_files = array($f_link);
$fd_names = array($fa_name);
$ext = array($exte);
if(($type == "image/pjpeg") || ($type == "image/pjpeg") || ($type == "image/jpeg")) { $fold = $i_path; }
else { $fold = $t_path; }
header("Content-Type: $type; name=\"$fd_names[$i]\".$exte");
header("Content-Length: ".filesize($total));
header("Content-Disposition: attachment; filename=$fd_names[$i].$exte");
header("Expires: 0");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
readfile($total);
exit;
} //end of number
unset($f_link,$type);
}//end of for
}
?>
Thankyou