<?php

$conn = pg_pconnect("dbname=jaime user=postgres password=postgres port=5433");
$name = $_POST['name'];
$temp = 'C:/Informatica/_www/desarrollo/pgimagen/imagenes/fotos.jpg';
//$temp = 'C:/xampp/tmp/fotos.jpg';

//C:\xampp\tmp\

$query = "select lo_export(image, '$temp') from image where name = '$name'";

$result = pg_query($query);

if($result)
{
	$query = "select * from image where name = '$name'";
    $result = pg_query($query);
    while ($line = pg_fetch_array($result))
    {
        $ctobj = $line["image"];
        echo "<IMG SRC=show.php>";
        printf ("<br/>".$line["name"]." - ".$line["day"]." ");
    }

}
else { echo "File does not exists."; }
pg_close($conn);

?>