Hi all out there in scriptville!!
I have a week and a half getting to this point and now I am stumpted can any one help?
What I have is on RedHAt7.2 with latest Postgresql and php versions, a database of largeobjects(jpegs), each with a unique text name. The goal is that this is a db of aerial photgraphs of landscapes. I can search and get displayed to the browser any image I want. However, when I right-button click on the image to save to /somewhere/imagename.jpg, I get /somewhere/image.php4 which is the name of the scipt which displays the file to the browser. Does any one have a suggestion as to how I may achieve this?
I have included my code and you are welcome to browse http://tashtego.otago.ac.nz/Images/search.html for a demo.
Many thanks. Stephen
Search.html
<head>
<title> Search </title>
<meta name="author" content="Stephen Harris">
</head>
<body bgcolor="#ffff88" text="#003366" link="#ff6600" vlink="ff6600" alink="#990033">
<center>
<font size=+2>
<!-- Creation of the form -->
<form action="image_querry_dynamic.php4" method="GET">
Image Keyword: <input type="Text"
name="descriptive_pattern" size="40" maxlength="60"> <br>
<p><input type="reset" value="Clear"><input type="submit" value="Search"></p>
</form>
<pre> Enter the name of the image</pre>
<p>eg picture, %ictur% etc.
<hr WIDTH="100%">
</center>
</font>
</body>
Image_querry_dynamic.php4
<head>
<title> Results </title>
<meta name="author" content="STEPHEN HARRIS"> </head>
<body bgcolor="#ffff88" text="#003366" link="#ff6600" vlink="ff6600" alink="#990033">
<hr WIDTH="100%">
<?php
$conn=pg_connect("host=localhost user=nobody dbname=imagedb");
if (!$conn)
echo("<b> An Error Occured </b>");
$headers=array("Image Name");
$alt_headers=array("Image Name");
// Execute Query
pg_Exec($conn,"SET DATESTYLE TO 'European';");
$result=pg_Exec($conn,"SELECT name
FROM images
WHERE name
LIKE '%$descriptive_pattern%'
ORDER BY name;");
//Creation of drop-down list box
$num=pg_numrows($result);
$i=0;
while ($i < $num) {
$rownum=pg_fetch_array($result, $i);
$name=$rownum["name"];
$option_block .="<OPTION value=\"$name\">$name</OPTION>";
$i++;
}
?>
<FORM action="phptest.php4" method="GET">
<CENTER><P>Image Name:<br>
<SELECT name="image_name">
<? echo("$option_block"); ?>
</SELECT>
<P><INPUT type="submit" value="submit"></p>
</CENTER>
</FORM>
<?
$rows=0;
if ($rows<pg_numrows($result))
{
$found=true;
}
// How many entities do we have ?
echo("<center>");
$entities=pg_numrows($result);
echo("<p><font color=#FF0000 size=+2> $entities entities </font></center>");
// Else none found
if (!$found)
echo("<center><b><u><font size=+4> Entity Not Found !!</font></u></b></center>");
echo("<hr WIDTH='100%'>");
//Creation of the header of the table
echo("<center><p><font color=#FF0000 size=+2>These are the entities.</font></center>");
echo("<center><table BORDER=1 CELLPADDING=4 CELLSPACING=0 COLS=pg_numfields($result) NOSAVE>");
//Fetch the elements from the database
echo("<tr>");
for ($i=0;$i<sizeof($alt_headers);$i++) {
echo("<th align=center> <font size=+2> $alt_headers[$i] </font> </th>");
}
echo("</tr>");
$rows=0;
while ($rows < pg_numrows($result)) {
$entity_description=pg_fetch_array($result,$rows);
echo("<tr>");
$fields=0;
while ($fields < pg_numfields($result)) {
echo ("<td align=center> <tt> $entity_description[$fields] </tt> </td>");
$found=true;
$fields++;
}
$rows++;
echo("</tr>");
}
echo("</table>");
// How many entities do we have ?
$entities=pg_numrows($result);
echo("<h2> $entities entities </h2>");
if (!$found)
echo("<b><u><font size=+4> Entity Not Found !!</font></u></b>");
echo("<hr WIDTH='100%'>");
pg_freeresult($result);
pg_close($conn);
?>
</body>
phptest.php4
<body>
<?
$conn = pg_Connect("host=localhost port=5432 user=nobody dbname=imagedb");
if (!$conn)
echo("<b> An Error Occured </b>");
// Execute Query
pg_Exec($conn,"begin");
$obj=pg_Exec($conn,"select jpeg from images where name='$image_name'");
$result_obj=pg_NumRows($obj);
$i=0;
while($i < $result_obj)
{
$ctobj=pg_Result($obj,$i,"jpeg");
echo("<img src=image.php4?Index=$ctobj>");
$i++;
}
//pg_Exec($conn,"end");
pg_freeresult($obj);
pg_close($conn);
?>
</body>
image.php4
<?
Header("Content-type:image/jpeg");
$conn=pg_Connect("host=localhost user=nobody port=5432 dbname=imagedb");
pg_Exec($conn,"begin");
$fhandle=pg_loopen($conn,$Index,"r");
pg_loreadall($fhandle);
pg_loclose($fhandle);
pg_Exec($conn,"end");
?>