i can upload an image and insert the information i want about it into a database, the problem is, im trying to insert the image itself into the database as a medium blob. im not sure what im doing wrong because when i echo the query and try selecting the image to view it after it has been inserted into the database, a bunch of funny looking symbols appear. is this the binary form of the image? how can i get around this? some of my code is below
$content = addslashes(fread(fopen($file,"r"), filesize($filetmpName)));
$query = "INSERT INTO $Images (Image_Name, Size, Image, Username, Type, URL) VALUES ('$filename', '$filesize', '$content', '$_SESSION[username]', '$filetype', '$URL')";
$result= MYSQL_QUERY($query);
echo $query;
$query = "SELECT Image, Type FROM $Images WHERE ImageId='11'";
$result= MYSQL_QUERY($query);
$data = @MYSQL_RESULT($result,0, "Image");
<img src="http://www.xxxxxxx.com/imageAd.php?file=11">
trying to insert image into database
Moderator: General Moderators
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
Re: trying to insert image into database
This is a very common design folly (a mistake we've all made) - the general consensus is to store the file in the filesystem and the meta in the DB. A search should locate a more detailed strategy for you.