Posted by:
kirti
(---.cable.ubr03.newm.blueyonder.co.uk)
hi guys! basically i've been trying to upload and download images into and from the database. now i've managed to upload picture into the database but the problem is when i download it, it shows me an empty webpage. i've been trying to work it out but its not happening.
i took working code example from my friend and tried that which also gives me an empty webpage with no error, no image showing. though the same code provides my friend with an image retreived from the database. do i need to change any setting son my wampserver?? i'm using wamp5 1.5.0.
please help. i've a deadline and this is driving me insane.
the code i'm using to download is:
<?php
if(isset($_GET['id']))
{
// connect to mySql
$session = mysql_connect("localhost", "root", ""
;
// select the 'dreamhome' database
mysql_select_db("dreamhome"
;
$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_array($result);
header("Content-length: $size"
;
header("Content-type: $type"
;
echo $content;
// close the connection
mysql_close($session);
exit;
}
?>
<html>
<head>
<title>Download File From MySQL</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
// connect to mySql
$session = mysql_connect("localhost", "root", ""
;
// select the 'dreamhome' database
mysql_select_db("dreamhome"
;
$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))
{
?>
<a href="../../Documents%20and%20Settings/KIRTI%20RAM/Local%20Settings/Temporary%20Internet%20Files/Content.IE5/VZ7OZ8PS/download.php?id=<?=$id;?>"><?=$name;?></a> <br>
<?php
}
}
// close the connection
mysql_close($session);
?>
</body>
</html>