I have a database which keeps some normal files in LONGBLOBS. I then call up
a file called download.php to retrieve the file from the database, echo out
it’s contents, and it’s type, and all that so they download it. However, if
the user clicks the download link, they download the actual download.php
file and if they open it, it’s blank. I’ve attached the code to
download.php. Any ideas why this is happening and how to fix it?

 

<?php

                if (isset($HTTP_GET_VARS['id'])) {

                                include('Connections/default.php');

                                mysql_select_db($database_default,
$default);

                                $id = $HTTP_GET_VARS['id'];

                

                                $query = "SELECT * FROM files WHERE
id='$id'";

                                $result = mysql_query($query, $default);

                                $row = mysql_fetch_array($result);

                                $new = $row['downloads'] + 1;

                                $query = "UPDATE files SET downloads='$new'
WHERE id='$id'";

                                $result = mysql_query($query, $default);

                                

                                $type = $row["ftype"];

                                $name = $row["fname"];

                                $size = $row["fsize"];

                                $id = $row["id"];

                                $data = urldecode($row["fdata"]);

                                

                                header("Content-type: $type");

                                header("Content-length: $size");

                                header("Content-Disposition: attachment;
filename=$name");

                                header("Content-Description: PHP Generated
Data");

                                

                                echo $data;

                                exit();

                }

?>

 

 

Thanks,

Stephen Craton

HYPERLINK "http://www.melchior.us"http://www.melchior.us -- HYPERLINK
"http://www.melchior.us/portfolio"http://www.melchior.us/portfolio

 

 


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.532 / Virus Database: 326 - Release Date: 10/27/2003
 

Reply via email to