In the last part of a script that loads the image into the database:
$qs = "FetchImage.php3?nbr=".$lastone;
echo "<center>";
echo "<image src='".$qs."'>";
Where $lastone is a reference to the image just inserted into the DB:
$lastone = mysql_insert_id($someonnection);
Notice that the <img> src is a php file - we have to change gears here and fetch
the image from the DB and set the content type accordingly to a binary type
from FetchImage.php3:
$db = mysql_select_db("fractalv", $someonnection) or die ("db");
$sql = "SELECT * FROM pictures WHERE picturesID =".$nbr;
$sql_result = mysql_query($sql,$someonnection) or die ("no result");
$RecordCount = mysql_num_rows($sql_result);
$row = mysql_fetch_array($sql_result);
$thisphoto = $row[picture];
$contenttype = $row[pictureType];
mysql_close($fvconnection);
header("Content-type: $contenttype");
echo $thisphoto;
?>
Make sense? Follow the link I gave to the previous post for more extensive
info...
Phil J.
Sharmad Naik wrote:
> I have written a small script having connectivity with postgresql which
> can upload an image and display the already uploaded images.
> But it doesn't display the uploaded images. I guess the problem lies somewhere
> in $file_url.
> Pls help me
>
> <HTML>
> <HEAD>
> <TITLE></TITLE>
> </HEAD>
> <?
>
> $database=pg_connect("dbname=testdb user=postgres")
>
> ?>
> <?
> if ($submit) {
>
> $result = pg_Exec($database,"INSERT INTO ".
> "images (mem_id,mem_image) VALUES(NULL,'$fupload_name')");
>
> $file_dir = "/tmp";
>
> $file_url = "http://sanico.sharmad.org";
> if (isset($fupload ))
> {
> if ($fupload_type == "image/jpg" ||$fupload_type == "image/jpeg")
> {
> copy ($fupload, "$file_dir/$fupload_name") or die ("Couldn't copy");
> echo("$file_dir/$fupload_name");
> }
> }
> }
>
> $result=pg_Exec($database,"SELECT mem_image from images");
> for($i=0;$i<pg_NumRows($result);$i++){
> $images=pg_Result($result,$i,0);
> copy ("$file_dir/$images",$ftupload);
> echo ( $images);
> echo ( $ftupload);
> echo ("<IMG SCR= $ftupload>");
> }
>
> ?>
> <BODY BGCOLOR="#FFFFFF">
> <FORM action="<? print $PHP_SELF?>" method="post"
> enctype="multipart/form-data">
> <!-- <INPUT TYPE="hidden" name="MAX_FILE_SIZE" VALUE="51200"> -->
> <INPUT TYPE="hidden" NAME="$fupload_name" VALUE="<? echo $fupload_name ?>">
> <INPUT TYPE=file name="fupload" VALUE=""><BR>
> <INPUT TYPE="submit" NAME="submit" VALUE="Send File to Web Server">
> </FORM>
> <A HREF="index.php" CLASS="content">Home page</A>
> </BODY>
> </HTML>
>
>
> -thanks
> --
> The secret of the universe is @*&í!'ñ^#+ NO CARRIER
> __ _ _ _ _
> |_|_||_||_||\/||_|| \
> _|| || || \| || ||_/
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]