Greetings All,
You helped be greatly last time I was here, hoping for a repeat.
I have a page at http://www.vfw10216.com/download_file.php that displays contents of my database that stores PDF files.
The contents field is type 'mediumblob' and attributes is 'binary'. The field does contain data in every record, as shown in the display results (only 5 records/files now).
Obviously I have the upload working. which is a form at http://www.vfw10216.com/upload_file.php
And, obviously the download page is finding and displaying the contents of the db field.
But, the links to the files don't work.
Here is my code so far. What do I need to do to it for the pdf files to actually download and open?
<?php
$query = "SELECT name, type FROM upload";
$result = mysql_query($query);
$name = 'name';
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
echo "<li> {$row['id']} Filename: <a href=download.php?id={$row['id']}> {$row['name']} </a> </li>";
}
?>
<?php
if(isset($_GET['id']))
{
// if id is set then get the file with the id from database
$id = $_GET['id'];
$query = "SELECT name, type, size, content" .
"FROM upload WHERE id = '$id'";
$result = mysql_query($query) or die('Error, query failed');
list($name, $type, $size, $content) = mysql_fetch_array($result);
header("Content-length: $size");
header("Content-type: $type");
header("Content-Disposition: attachment; filename= $name");
echo $content;
exit;
}
?>