All,
I have a file that I stored on my server. I put the file name and the file type in the database. These are word and excel and pdf files. I tried to pull the file name and type from the database to fill the correct headers and open the file. It doesn't seem to be working though. Can someone please take a look at what I tried to do:
$barid = $_GET['id'];
$sql = "Select menu, menu_type from bars where id='$barid'";
$result = mysql_query($sql);
$resultset = mysql_fetch_array($result);
if($resultset['menu_type'] == "application/msword"){
$extension = ".doc";
}else if($resultset['menu_type'] == "application/pdf"){
$extension = ".pdf";
}else{
$extension = ".xls";
}
header("Content-Type: application/$resultset[menu_type]");
header("Pragma: no-cache");
header("Expires: 0");
fopen("/home/website/public_html/menus/$resultset[menu].$extension","r");
Thanks for your help in advance. This file is called viewmenu.php and it is being invoked by a URL called viewmenu.php?id=10 or something like that where the id can change. However it currently tries to open up the viewmenu.php file instead of the pdf, doc or xls file that I want it to.