ok i got files uploading to my database alright. but having problems downloading files from the database, it shows as a link and when i click on the link nothing happens.
<In your download.php
you make the links and exit
. This means you will not go any further than your exit
call.
<?php
}
}
exit;
mysql_close()
?>
You need to rethink your logic in the download file. You also call
header("Content-length: $size");
exit;
print $content;
I scan thoroughly your code and here is the final answer.
<?php
require 'connect.php';
$query = "SELECT id, name 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) = mysql_fetch_array($result)){
echo "<a href=\"download.php?id=\$id\">$name</a><br>";
}
}
if(isset($_GET['id'])){
$id = $_GET['id'];
$query = "SELECT name, type, size, content FROM upload WHERE id = '$id'";
$result = mysql_query($query) or die('Error, query failed');
list($name, $type, $size, $content) = mysql_fetch_row($result);
header("Content-Disposition: attachment; filename=\"$name\"");
header("Content-type: $type");
header("Content-length: $size");
print $content;
}
?>