Downloading file from mysql database
I am trying to allow users to download files from a mysql database using php. I've already successfully uploaded the file and its name to the table attachments.
Here is the link they click on:
echo "<a href=\"/page.php?&action=download&id=$id\">$filename</a>";
'
and here is the action download:
if($action == 'download'){
$query = $db->query("SELECT * from attachments where id=$id");
$file = $db->fetch_array($query);
// Send the attachment
header("Content-disposition: filename=$file[filename]");
header("Content-Length: ".strlen($file[attachment]));
echo $file[attachment];
}
Is there something I'm doing wrong? The browser just hangs when I click the link.
airoid3000 posted this at 06:07 — 16th June 2005.
They have: 71 posts
Joined: Mar 2004
does anyone have any way of downloading a file from a mysql database? i need help!
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.