PHP:<?php
ini_set ("display_errors", "1");
error_reporting(E_ALL);
include 'stdlib.php';
$conn= new Mysqli('localhost', 'imm_user', 'root', 'immobili');
$id = (int)$_GET['id'];
$result= $conn->query("SELECT file, nome, file_type, file_size FROM immagine WHERE id_ann=$id;");
$row = $result->fetch_row();
$image = $row[0];
$image_type= $row[2];
$size = $row[3];
$ext = explode('/',$image-type);
header("Content-type: $image_type");
echo $image;
?>