Hello, I am creating a site which let's users download files. I need some guidance on the download.php file. I need help with retrieving the actual file contents.
Here is my code:
<?php
$file = $_GET['id'];
$name = $_GET['name'];
require("connect.php");
$qry = mysql_query("SELECT name FROM demos WHERE id=$file");
$row = mysql_fetch_array($qry);
if(file_exists("files/{$row['name']}")){
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=$name");
}
else{
echo "file does not exist";
}
?>
This is bringing up the download save/open box, but the file is empty. (0kb).
I have read about fread() etc but I cannot understand how to do it.
I was looking for some guidance and help on achieving this.
Kind Regards,
Labtec.