hi since my last post on here i've been working hard and learning a fair a bit of php (im no master obviously, but im still enjoying it). however im close to pulling my hair out now.
heres my problem, im storing small images on my database as a mediumblob which for the website im trying to build is my best option. all i want to do is loop echo out all the images from the database below my form but i keep getting all the encrypted text not the image..... i've tried just about every online tut i can find now and looked in books but no joy. any help would be amazing
heres my create table
CREATE TABLE `upload` (
`id` int(11) NOT NULL auto_increment,
`name` varchar(30),
`type` varchar(30),
`size` int(11),
`content` mediumblob,
PRIMARY KEY (`id`)
)
the upload code im using
<?php
$db_link = mysql_connect("localhost", "testing", "testing");
mysql_select_db("testing");
if(isset($_POST['upload']) && $_FILES['userfile']['size'] > 0)
{
$fileName = $_FILES['userfile']['name'];
$tmpName = $_FILES['userfile']['tmp_name'];
$fileSize = $_FILES['userfile']['size'];
$fileType = $_FILES['userfile']['type'];
$fp = fopen($tmpName, 'r');
$content = fread($fp, filesize($tmpName));
$content = addslashes($content);
fclose($fp);
if(!get_magic_quotes_gpc()) {
$fileName = addslashes($fileName);}
$query = "INSERT INTO upload (name, size, type, content ) ".
"VALUES ('$fileName', '$fileSize', '$fileType', '$content')";
mysql_query($query) or die('Error, query failed');
echo "<br>File $fileName uploaded<br>";
}
?>
<form method="post" enctype="multipart/form-data">
<table width="350" border="0" cellpadding="1" cellspacing="1" class="box">
<tr>
<td width="246">
<input type="hidden" name="MAX_FILE_SIZE" value="2000000">
<input name="userfile" type="file" id="userfile">
</td>
<td width="80"><input name="upload" type="submit" class="box" id="upload" value=" Upload "></td>
</tr>
</table>
</form>
..........................
i just can't find anything to add on the end that will work!!!
any help would be great
thank you
stephen