I want to create a file called "download.php" to handle the downloading of brochures. What I am trying to achieve is as follows:
1) From the brochure page send the brochure id to the download.php (No problem with this)
2) Select the correct brochure from the database by the id sent from brochure page
3) Insert the directy name + file name into the header file area. (this is messed up somehow)
I'm new to php and not sure how to write the variables into the header. The way I have it at the moment it's not placing in the dir or the file name, when I click on download instead it opens the download window, but just the id is in there instead of the file name. Thruth is I'm not sure how to get it to work, I've been trying all morning. If anyone out there could tell me what I've done wrong I'd be greatful.
As I'm going no where fast! Have tried searching net for solution, but haven't come up with anything.
Big. big thank you in advance,
Linda
<?php
$id=$_GET['id'];
include '../inc/hearse.inc';
@mysql_connect($host,$user,$password) or die ("Unable to connect to server!");
@mysql_select_db($database) or die( "Unable to connect to database, please try later!");
$query=" SELECT * FROM brochure WHERE id='$id'";
$result=mysql_query($query);
mysql_close();
$filename=mysql_result($result,"filename");
$dir=mysql_result($result,"dir");
header('Content-type: application/pdf');
header('Content-Disposition: attachment; filename="'.basename($dir,$filename).'"');
?>