View Full Version : download files or datas in the database table.
saranya
04-19-2007, 06:39 AM
hello,
i have a table t1 which contains a field name related_files(blob). i can display path .now i want to put a download option if i click there the corresponding file will be download for view. it is possible. please help me.
Umang
04-21-2007, 02:26 PM
Are you using PHP? Then you should link it to a download.php file. I hope you have an ID field also. When you make the link say (e.g. your id is 5) download.php?id=5. In download first check if $_GET["id"] is set and is numeric. I also hope that you have a filename field. Then do something like this:
<?php
//Finish connecting to mysql database before this
if(!(isset($_GET["id"]) && is_numeric($_GET["id"]))
die("Invalid ID");
$rs = mysql_query("select * from `t1` where `id` = '" . mysql_real_escape_string($_GET["id"]) . "' LIMIT 1") or die(mysql_error());
while($row = mysql_fetch_assoc($rs))
{
header('Content-Disposition: attachment; filename="' . $row["filename"] . '"');
echo($row["related_files"]);
}
//Close the connection using mysql_close() ...
//Then you are done!
?>
Umang
saranya
04-22-2007, 06:22 AM
ya i got the answer thanku for ur query.now i want to update the file. i created a icon in related text area in the edit.php page. if i click that i want update my file. can u help me.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.