in reply to How to read a stored file from database and show in browser

You need 2 scripts, e.g. pdf_index.cgi and pdf_display.cgi. The index page creates the links to the other cgi with an id parameter (assuming it is unique) to determine the pdf. This example puts the links in a table with the other fields.
#!perl use strict; use CGI qw(:standard); use DBI; my $dbh = get_dbh(); # html page print header,start_html; my $sql = 'SELECT id,name,description,vers FROM software_repos'; my $sth = $dbh->prepare($sql); $sth->execute(); print q!<table border="1" cellspacing="0" cellpadding="3"> <tr> <td>ID</td> <td>Name</td> <td>Description</td> <td>Version</td> <td>PDF</td> </tr>!; while (my @f = $sth->fetchrow_array()){ print qq!<tr> <td>$f[0]</td> <td>$f[1]</td> <td>$f[2]</td> <td>$f[3]</td> <td><a href="pdf_display.cgi?id=$f[0]" target="_blank">pdf</a></td> </tr>\n!; } print q!</table>!; print end_html; # whatever you need to get a connection sub get_dbh{ my $database = ""; my $user = ""; my $pw = ""; my $dsn = "dbi:mysql:$database:localhost:3306"; my $dbh = DBI->connect($dsn, $user, $pw, { RaiseError => 1, AutoComm +it => 1 } ); return $dbh; }
The other script to display the pdf is relatively simple
#!perl use strict; use CGI qw(:standard); use DBI; my $id = param('id'); my $dbh = get_dbh(); my $sql = "SELECT bin FROM software_repos WHERE id=?"; my ($pdf) = $dbh->selectrow_array($sql,undef,$id); print header('application/pdf'), binmode(STDOUT); print $pdf; # whatever you need to get a connection sub get_dbh{}
poj