Hi,
Im having some problems with displaying images that are saved in my DB. Ive saved them as mediumblob, the code finds the correct image (ive checked it with outputting the filename) but it wont display it. Firefox tells me something like "The image cant be displayed cause theres something wrong with it" and IE only shows the HTML code and the images binary data.
Code:
<?php
$film = $_GET['filmNr']; // Unique identifier
$getmovie = mysqli_query($connection, "SELECT * FROM Film WHERE filmNr='$film'");
if (!$getmovie) {
$error = 'Ett fel inträffade under hämtningen av film: ' . mysqli_error($connection);
include 'error.inc.php';
exit(); }
while ($movie = mysqli_fetch_array($getmovie)) {
$movies[] = "<p>Titel: " . $movie['titel'] .
"<br />Pris: " . $movie['pris'] . " kronor <br /> Beskrivning: " .
$movie['beskrivning']; }
if (empty($movies)) {
$error = 'Det finns inga sparade filmer. ';
include 'error.inc.php';
exit(); }
$getimage = mysqli_query($connection, "SELECT * FROM Bild WHERE filmNr='$film'");
$image = mysqli_fetch_array($getimage);
$filnamn = $image['filnamn']; // Filename
$filtyp = $image['filtyp']; // FIletype
$fildata = $image['fildata']; // Filedata
$disposition = 'inline';
header("Content-type: $filtyp;");
header("Content-disposition: $disposition; filename=$filnamn");
header('Content-length: ' . strlen($fildata));
foreach ($movies as $movie) { ?>
<p> <?php
echo $movie; ?>
<img src="<?php echo $fildata; ?>" />
</p>
<?php }
?>
Some help would be appreciated ^^