I need to do a web page for a client to upload images to a data base and display them.
I am achieve to upload the images into a database, but I\'m having trouble di
Depending on the file use inline base64 encoding. This is done with:
echo '<img src="data:image/jpeg;base64,'.base64_encode( $image ).'"/>';
Font: base64_encode
OR
Put the T
upperCase (Type), because can giving error in IE. Try printing with the function file_get_contents.
header('Content-Type: image/jpeg');
echo readfile($image);
Escaping an image file with addslashes
will probably corrupt it, the imagesize
test should be sufficient
I wouldn't store any image in a database. You should save it as file, and store the file's name in the database. You can then configure which directory an image gets served from without worrying about the full path to the image, or storing binary data in your db (yuck).
Try changing:
$image = mysql_query("SELECT * FROM blog WHERE id=$id");
to:
$image = mysql_query("SELECT * FROM blog WHERE id = '$id'");