I thought I had this working until I tried to download a file. When you click download it opens the popup box allows you to save the file, and download the file. The download goes very quickly, and turns up and empty zip file. Most of these were placed in the sql manually. A few were done using an upload script. Both methods have the same effect. These files are working and are not corrupt. I'm redoing an existing html link downloads area, and turning it sql, so I know these files work for download. One last thing, when I enter the direct link >> download.php?id=35 for example still downloads the file like it should but its empty as well. What do I need to change here? Any help is greatly appreciated.
EDIT == If this helps for a clue, on the popup it shows the size as 232 or 233 bytes on every single file. even thought when it's uploaded it puts the correct size
in the datebase ( I tested a few dozen. )
<?php
error_reporting(E_ALL);
if(isset($_GET['id']))
{
include 'inc/config.php';
include 'inc/opendb.php';
$id = $_GET['id'];
$query = "SELECT name, type, size, path, dis, icon FROM upload WHERE id = '$id'";
$result = mysql_query($query) or die('Error, query failed');
list($name, $type, $size, $icon, $dis, $filePath) = mysql_fetch_array($result);
header("Content-Disposition: attachment; filename=$name");
header("Content-length: $size");
header("Content-type: $type");
header("Content-type: $dis");
header("Content-type: $icon");
readfile($filePath);
include 'inc/closedb.php';
exit;
}
?>
<html>
<head>
<title>Downloads</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
a {
color: #FFFFFF;
}
a:visited {
color: #FFFFFF;
}
a:active {
color: #FFFFFF;
}
a:hover {
color: #FFFFFF;
}
.style1 {
border: 2px solid #008000;
background-color: #000000;
}
.style3 {
text-align: center;
border: 2px solid #008000;
background-color: #000000;
}
.style4 {
text-align: right;
border: 2px solid #008000;
background-color: #000000;
}
.style5 {
text-align: right;
border: 2px solid #008000;
background-color: #000000;
white-space: nowrap;
}
</style>
</head>
<body style="color: #FFFFFF; background-color: #000000;">
<center><img src="../images/Dl2.gif"></center><br><center> <strong>Files = <img src="../images/file.gif"> Liners = <img src="../images/liner.gif"> Local Band Music = <img src="../images/mp3.gif"></strong></center>
<?php
include 'inc/config.php';
include 'inc/opendb.php';
$query = "SELECT id, name, dis, icon FROM upload";
$result = mysql_query($query) or die('Error, query failed');
if(mysql_num_rows($result) == 0)
{
echo "Database is empty <br>";
}
else
{
while(list($id, $name, $dis, $icon) = mysql_fetch_array($result))
{
?>
<center><table style="width: 50%; float: left; height: 42px;" class="style1" align="left">
<tr>
<td class="style5" style="width: 27px; height: 23px;"><img src="../images/<?=$icon;?>.gif"></td>
<td style="width: 62%; height: 23px;" class="style3"><?=$dis;?></td>
<td class="style4" style="width: 140px; height: 23px;"><a href="download.php?id=<?=$id;?>"><img src="../images/download.gif" height="23" width="140" border="0"></a></td>
</tr>
</table>
</center>
<?php
}
}
include 'inc/closedb.php';
?>
</body>
</html>