<?
include ("connection.php");
include ("frames_header.php");


$id=$_POST["embryoid"];

if (strlen($_FILES['lsmfile']['tmp_name'])==0)
	{
	print "<br><br><center>Please submit a file containing the distances data.</center>";
	include ("frames_footer.php");
	return;
	}

$requete="SELECT * from \"EMBRYO\" where \"EMBRYO_ID\"='$id'";
$stmt=pg_query($c,$requete);

pg_query($c,"begin");

if (strlen($_FILES['lsmfile']['tmp_name'])>0)
{
$f1=fopen($_FILES['lsmfile']['tmp_name'],"r");
$text1=fread($f1,filesize($_FILES['lsmfile']['tmp_name']));
fclose($f1);

$oid1=pg_lo_create($c);
$requete="UPDATE \"EMBRYO\" set \"LSM\"='$oid1' where \"EMBRYO_ID\"='$id'";
$stmt = pg_query($c,$requete) or die ("<strong> ERROR </strong>".pg_last_error($c));
$handler=pg_lo_open($c,$oid1,"w")  or die ("Error ... Contact the administrator !");
pg_lo_write($handler,$text1)  or die ("Error ... Contact the administrator !");
pg_lo_close($handler)  or die ("Error ... Contact the administrator !");


}
fclose($handle);


pg_query($c,"end");


?>
<SCRIPT LANGUAGE="JavaScript"> javascript:opener.location.reload(); self.close(); </script>



<?
include ("frames_footer.php");
?>