jeudi 26 mars 2015

longblob image not showing

Im bussy with a schoolproject and i found a problem. I can't echo a image from a dataase. The problem is that the image is saying that there is no image found. The picture is in the database and i in a object called foto.



public function getfoto() {
require('../../config.php');
$sql = "SELECT foto FROM producten WHERE productID = ?";
if ($stmt = $mysqli->prepare($sql)) {
$stmt->bind_param("i", $this->id);
$stmt->execute();
/* bind result variables */
$stmt->store_result();
$stmt->bind_result($foto);

return '<img src="data:image/jpeg;base64,'.base64_encode($foto).'" class="thumbnail profile-img"/>';
/* close statement */
$stmt->close();
}else{
echo "Execute failed: (" . $stmt->errno . ") " . $stmt->error;
printf("Errormessage: %s\n", $mysqli->error);
}
}


upload file:



$product = new product(null, $_POST['productnaam'], $_POST['categorie'],$_POST['omschrijving'],$_POST['min-vooraad'],$_POST['status'],$_POST['prijs']);

$foto = $mysqli->real_escape_string (addslashes(file_get_contents($_FILES["image"]["tmp_name"])));
$product->storefoto($foto);

Aucun commentaire:

Enregistrer un commentaire