I have some problems here and I hope someone can help me. unfortunately I couldn't find a solution yet so you are my last hope.
I upload an image to my database but I cant display it. What I get is this icon when an image cant be find or load, but my database is full of pictures :-/
This is my PHP code:
<?php
$dbhost = "localhost";
$dbuser = "DBConnector";
$dbpassword = "root";
$db = "phplogin";
$b = $_POST['bildbestaetigen'];
if(isset($b)){
if(getimagesize($_FILES['bild']['tmp_name'])== FALSE)
{
echo "Choose a picture.";
}
else
{
$image= addslashes($_FILES['bild']['tmp_name']);
$name = addslashes($_FILES['bild']['name']);
$image= file_get_contents($image);
$image= base64_encode($image);
saveimage($name,$image);
}
}
displayimage();
function saveimage ($name,$image){
$link = mysqli_connect("localhost","root","") or die("Verbindung zur Datenbank konnte nicht hergestellt werden!");
mysqli_select_db($link,"phplogin") or die ("kann nich finden ");
$result= mysqli_query($link, "insert into bilder (name,bild) values ('".$name."','".$image."')");
if($result)
{
echo "Image uploaded";
}
else
{
echo "<br/> Image not uploaded";
}
}
function displayimage(){
$link = mysqli_connect("localhost","root","") or die("Verbindung zur Datenbank konnte nicht hergestellt werdengjghghghh");
mysqli_select_db($link,"phplogin") or die ("kann nich finden ");
$result = mysqli_query($link,"SELECT * from bilder");
while( $row = mysqli_fetch_array($result));
{
echo '<img height="300" width="300" src="data:bild;base64,'.$row[2].' ">';
}
mysqli_close($link);
}
?>
I tried so many things with out luck.
I hope someone can help me!