Vive Corp.
 
 
     Displaying images on the web page
 
Services Products Support Downloads Contact Us About Us Site map

Software Development

Since 1991

 
    Displaying images using Perl:          
 
Retrieving image from a database is much easier task if you compare it to uploading. Here is Perl script you can use to get the image from the database and put it on your web page.

Perl script (for MySQL)

#!/usr/bin/perl
###########################################################
#   getPicture.cgi                     Version 2.1
#   Copyright 1998-2007 Vive Corp.     All Rights Reserved
#   http://www.vive.net                   
#
#   usage getPicture.cgi?file_name

use DBI;

#
# Define variables to fit your enviroment
#
my $database="test";
my $table="temp_image";
my $user="user name";
my $password="password";
my $hostname="database host name";


#
#   Do not edit below
#
my $in=$ENV{QUERY_STRING};
my $dsn="DBI:mysql:database=$database;host=$hostname";
my $dbh=DBI->connect($dsn, $user, $password); 
unless( $dbh ){
    print "Unable to connect to database";
    exit;
}
my $sth=$dbh->prepare("select Picture from 
			$table where File_Name='$in'");
$sth->execute();
my @data=$sth->fetchrow_array();
print "content-type: image/gif\n\n";
print $data[0];
$sth->finish();
$dbh->disconnect(); 
###########################################################

To make your web page work with this script you need to insert the following code into your html page:

<IMG SRC="getPicture.cgi?test.gif">
      Products:

Image2db
dataPro
SqlPro

Download Image2db
Image2db

Displaying images using ASP

 
             
 
Services | Products | Support | Downloads | Contact Us | About Us | Site Map
Copyright 1998-2007 Vive Corp. All rights reserved.