roscoeh23
asked on
Problem with PHP download script.
I have a problem with my download script. It is meant to downlaod a longblob from the mysql database. The problem is it does not work safari (it tried to download the php file) or IE7 - (It is corrupt) but works on ie6 and firefox. Any ideas where I am going wrong?
<?php
if(isset($_GET['id']))
{
// if id is set then get the file with the id from database
include("/home/trisco/publ ic_html/se cure/scrip ts/connect .php");
$id = $_GET['id'];
$query = "SELECT file_name, type, size, content FROM results WHERE id = '$id'";
$result = mysql_query($query) or die(mysql_error());;
list($file_name, $type, $size, $content) = mysql_fetch_array($result) ;
/*echo $file_name;
echo $type;
echo $size;*/
header("Content-Type: $type");
header("Content-Dispositio n: attachment; filename=$file_name");
header("Content-Length: ".filesize($file));
header("Accept-Ranges: bytes");
header("Pragma: no-cache");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-transfer-e ncoding: binary");
echo $content;
exit;
}
?>
<?php
if(isset($_GET['id']))
{
// if id is set then get the file with the id from database
include("/home/trisco/publ
$id = $_GET['id'];
$query = "SELECT file_name, type, size, content FROM results WHERE id = '$id'";
$result = mysql_query($query) or die(mysql_error());;
list($file_name, $type, $size, $content) = mysql_fetch_array($result)
/*echo $file_name;
echo $type;
echo $size;*/
header("Content-Type: $type");
header("Content-Dispositio
header("Content-Length: ".filesize($file));
header("Accept-Ranges: bytes");
header("Pragma: no-cache");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-transfer-e
echo $content;
exit;
}
?>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ie maybe just have the essentials for now:
header("Content-Type: $type");
header("Content-Dispositio
echo $content;
Also may I ask why you are not just using the $size variable for this line?:
header("Content-Length: ".filesize($file));