I am storing images on a mySQL server as mediumblobs. When I try to display them with the following code, some browsers(such as safari and EI) download the image instead of displaying them. Is there a way to display them which is browser independent?
$query = "SELECT image FROM images WHERE id=?";
$stmt = $dbc->prepare($query);
$stmt->bind_param("i",$id);
$stmt->execute();
$stmt->store_result();
$stmt->bind_result($image);
$stmt->fetch();
header("Content-Type: image/jpg");
echo $image;
Thanks in advance