Any ideas why the download doesnt work correctly Andrew?
Think its to do with headers. The file save window opens with test as the name.
if(!empty($_GET))
{
// Connect to database
include('../../db_connect.php');
// declare variables
$id = $_GET['id'];
$id2 = $_GET['id2'];
$id3 = $_GET['id3'];
$id4 = $_GET['id4'];
// check which file selected
switch(TRUE)
{
case ('$id'):
$query = "SELECT name, type, size, content ".
"FROM centralised_archive.mergers ".
"WHERE id = '$id'";
break;
case ('$id2'):
$query = "SELECT name, type, size, content ".
"FROM centralised_archive.rights ".
"WHERE id = '$id2'";
break;
case ('$id3'):
$query = "SELECT name, type, size, content ".
"FROM centralised_archive.spin_offs ".
"WHERE id = '$id3'";
break;
case ('$id4'):
$query = "SELECT name, type, size, content ".
"FROM centralised_archive.splits ".
"WHERE id = '$id4'";
break;
default:
echo 'None selected';
break;
}
//echo $query.'<br />';
$result = mysql_query($query) or die(mysql_error());
list($name, $type, $size, $content) = mysql_fetch_array($result);
// Set Headers
if(isset($_SERVER['HTTP_USER_AGENT']) && preg_match("/MSIE/", $_SERVER['HTTP_USER_AGENT']))
{
// IE Bug in download name workaround
ini_set( 'zlib.output_compression','Off' );
}
header('Content-type: ' . $type);
header('Content-length: '. $size);
header("Pragma: public");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header('Content-Disposition: attachment; filename="' . $name . '"');
print($content);
exit;
}