Hi all, I am cannot work out what is wrong with the following code. The objective is to download several files one after the other (this code only shows 2 files) where the filename is obtained from a mysql table (that part works well)
....
$filename=mysql_result($result, 0);
// echo $filename; // this shows a correct filename
header('Content-Description: File Transfer');
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header('Content-Type: audio/mpeg');
header('Content-Disposition: attachment; filename='.$id_token.'.mp3');
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Pragma: public');
header('Content-Length: ' . filesize($filename));
ob_clean();
flush();
session_write_close();
set_time_limit(0);
readfile($filename) or die("File not found."); //this worked fine
ob_clean();
flush();
$filename=mysql_result($result, 1);//
echo $filename; // //this prints nothing
header('Content-Description: File Transfer');
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header('Content-Type: audio/mpeg');
header('Content-Disposition: attachment; filename='.$id_token.'.mp3');
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Pragma: public');
header('Content-Length: ' . filesize($filename));
ob_clean();
flush();
readfile($filename) or die("File not found."); //this did nothing
ob_clean();
flush();
The result of this code is that the first file was downloaded well, but the second one was not. No error message was given.
How can I get the second (and subsequent files) to download correctly? What am I doing wrong?
Many thanks
George