Reputation: 1
<?php
ob_start();
session_start();
require_once('name.php');
if(!isset($_GET['e']))
{
header('HTTP/1.1 204 No Content');
exit();
}
if(empty($_SESSION['id']))
{
header('Location: login.php');
exit();
}
$id=$_GET['e'];
//database login information removed
$statement2=$db->prepare('select * from event2 where id=:id and userid=:uid');
$statement2->execute(array('id' => $id,
'uid' => $_SESSION['id']));
if($statement2->rowCount()==0)
{
header('HTTP/1.1 204 No Content');
exit();
}
$row=$statement2->fetch();
$image=$row['image'];
$realimage=imagecreatefromstring($image);
header('Content-type: image/jpeg');
$realimage;
ob_end_flush();
?>
I'm receiving an "Image 'image link' cannot be displayed because it contains errors." I've tried changing the content header position around to various places and cannot get it to work. I've downloaded the image straight from the database and it does reproduce properly. When opening the page in chrome, I'm presented with a tiny little green stock picture.
Upvotes: 0
Views: 2114
Reputation: 23787
What about outputting the image?
imagejpeg($realimage);
You're missing an imagejpeg
before the $realimage;
. (imagejpeg
or the other appropriate image* functions for outputting.)
By the way, why don't you output directly $image
(via echo
) instead of first parsing the image data as image?
Upvotes: 1