I have the following that is supposed to download files using the header function. Everything appears to be working except the download does not complete. All the info is stored in a DB, I have searched and found examples with a direct link to the file but not using a DB instead.
The download dialog appears with the correct filename and mime/type, all from the DB, the only problem is the filesize. The file used for testing is 1.6mb stord in the DB as 1631613, the script only downloads 12kb of the file. I have tried the script in Opera, IE6 and Firefox with the same results each time.
Can someone point me in the right direction please?

PHP Code:

if (isset(
$_GET['id']) && ctype_digit($_GET['id'])){
$id $_GET['id']; 
} else {
"File does not exist";

$conf config();

$sql "SELECT * FROM skinz_images WHERE subs_id = ".$id." AND status='1'";
$res $database->DB_Query($sql$skinz) or die(mysql_error());
$row mysql_fetch_assoc($res);

$file =  $conf['subs_image_path'] . $row['subs_thumb_file'];

$size $row['subs_zsize'];
$content $row['subs_mime'];
$name $row['subs_download_file'];

header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: public");
header("Content-type: $content");
header("Content-Disposition: attachment; filename=$name");
header("Content-length: $size");
header("Content-Transfer-Encoding: binary");