Reputation: 452
I'm writing my first PHP code and I'm building a form in which the user uploads an image, the image is save in the directory and the name is saved in the database. Than I have a page that displays that that data from the database i want it to show to image.
$imgdir = 'images/' . $result['fileName'];
$imgsrc = ImageCreateFromJpeg($imgdir);
header('Content-Type: image/jpeg');
imagejpeg($imgsrc);
the output i get is this(notice the block on top left)
but if remove header('Content-Type: image/jpeg'); i got this output(whats in blue is the dir to the image i echoed to check if correct, and it is).
thanks!
Upvotes: 1
Views: 1424
Reputation:
You'd better use a simple html img
tag, i guess, no need to overdo things :-)
<img src="<?php echo 'images/' . $result['fileName'] ?>" alt="" />
Upvotes: 1