bizarre header problem for file download

wxdqz

New Member
I have a script called download.php that correctly retrieves the relevant data and file information for files I store in a database.

When I try and allow users to download them, it ends up sending an html file of the current page, named "interface.htm" -- interface is actually the directory that the scripts are running in, which is odd.

here is the code/headers :

<?php

if($attachment_id)
{
include("connect.inc");
$sql = "SELECT data, filetype, filename, filesize " .
"FROM attachments " .
"WHERE attachment_id=$attachment_id";

if(!$result = mysql_query($sql,$connection))
return 0;

if (!$row = mysql_fetch_object($result))
echo "<p>Error : could not locate valid attachment</p>";

$data = $row->data;
$file_type = $row->filetype;
$file_name = $row->filename;
$file_size = $row->filesize;
Header("Content-Disposition: attachment; filename=$file_name");
Header("Content-Type: foo");
Header("Content-Length: $file_size");
Header("Content-Transfer-Encoding: binary");
echo $data;
};
?>

ANY HELP would be appreciated?.....email me if you need some clarifying info....
 
Back
Top