open(frontFILE, $imageFront.'.gif'); read (frontFILE, $blobFront, -s "$imageFront"); close frontFILE; open(backFILE, $imageBack.'.gif'); read (backFILE, $blobBack, -s "$imageBack"); close backFILE; my $sth=$db->prepare("Insert INTO docs (FrontImg,BackImg,docID) values (?,?,?); $sth->execute($blobFront, $blobBack, $docID) or die $sth->errstr; #### my $whichImage = 'e5c59e0d-fc0e-4d8e-9fa5-7b3bac6f8f25'; #getting the image from the db my $db=DBI->connect('DBI:Sybase:server='.$server,$sql_user,$sql_password); $db->do("use ".$database) ; my $statement = "select FrontImg, BackImg, docid from docs where docid = '$whichImage'"; my @rows=@{$db->selectall_arrayref($statement, {Slice => {}})} ; unless( @rows){die "$statement \ndidn't find the image ".@rows;} #there should only be one record returned -- docid is the primary key my $data = $rows[0]; #to get the same image from file instead of the db: open FILE, "<$filebase".'/1001-1-B.gif' ; my $blob; read(FILE, $blob, -s $Lockbox::Web::CONFIG{filebase}.'/1001-1-B.gif'); close FILE; #the following line displays only the dreaded empty box w/a red 'x' #instead of the image from the database print $q->header(type=>'image/gif', Content_Length=>length($data->{BackImg})).$data->{BackImg} ; #the following line displays the image from the file correctly #but i need to get it from the db instead #print $q->header(type=>'image/gif', Content_Length=>length($blob)).$blob ; if($blob ne $data->{BackImg}){die $data->{BackImg}."\nlength=".length($data->{BackImg})."\nfile image = ".$blob."\nlength=".length($blob);}