<?php  
$uploadDir = 'uploads/';  

$requestUri = $_SERVER['REQUEST_URI'];  
$parts = explode('/', $requestUri);  

$id = isset($parts[3]) ? intval($parts[3]) : 0;  

$imageName = 'screenshot_' . $id . '.png';  
$imagePath = $uploadDir . $imageName;  

if (file_exists($imagePath)) {  
    header('Content-Type: image/png');  
    readfile($imagePath);  

    unlink($imagePath);  
} else {  
    header("HTTP/1.0 404 Not Found");  
    echo "Image not found.";  
}  
?>  