Hi
Gurus,
Let me define the
problem here :
In our website, user
can see the link for list of excel files that they view. [ These excel
files are stored in database as a blob.] Whenever user clicks on any one
the link, by using the unique id, we extract the blob from the database and
display to user in a browser window.
Till this it's
fine...
First time user
clicks on link, the Excel file opens in IE browser without any
problem.
Next time, user
clicks on any other link to open the corresponding Excel file, following Warning
dialog comes up
"A document with
name 'download_excel.cgi' is already open. You cannot open two
documents with the same name, even if the documents are in different folders. To
open the second document, either close the document that's currently open, or
rename one of the documents."
And after that if
user tried to read the excel by clicking on the pages inside, behaviour is very
strange.
One thing I'm not
able to understand is, why excel file name is coming as <cgi-name> which
is trying to open instead of the file name that has been given in a
"Content-disposition" header. It's defeating the purpose of
setting the filename.
Here I'm attaching
the script that reads the file object from the database and display to
user.
How to set the file
name in header so that it doesn't pick up the cgi-name which is trying to
display it in a browser ?
Please help me
,
thanks,
rajendra
----------------------------------------------------------------------------------------------------------------
sub
ReadFile
{
my ($objid) = @_;
my ($SQL, $sth, $RS);
my ($fil) = new CGI;
{
my ($objid) = @_;
my ($SQL, $sth, $RS);
my ($fil) = new CGI;
$SQL =
"SELECT file_name, mime_type ";
$SQL .= "FROM links ";
$SQL .= "WHERE objid = ?";
$SQL .= "FROM links ";
$SQL .= "WHERE objid = ?";
$sth =
$dbh->prepare($SQL) #--- Prepare the SQL statement
or die "\nCan't prepare SQL statement: \n$DBI::errstr\n\n${SQL}\n";
or die "\nCan't prepare SQL statement: \n$DBI::errstr\n\n${SQL}\n";
$sth->execute($objid) #--- Execute the SQL statement
or die "Can't execute SQL statement: $DBI::errstr\n";
or die "Can't execute SQL statement: $DBI::errstr\n";
my
($file_name, $mime_type) = $sth->fetchrow_array();
$dbh->{LongReadLen} = 15 * 1048576;
$dbh->{LongTruncOk} = 1;
$dbh->{LongTruncOk} = 1;
$SQL =
"SELECT file_source ";
$SQL .= "FROM links ";
$SQL .= "WHERE objid = ?";
$SQL .= "FROM links ";
$SQL .= "WHERE objid = ?";
$sth =
$dbh->prepare($SQL) #--- Prepare the SQL statement
or die "\nCan't prepare SQL statement: \n$DBI::errstr\n\n${SQL}\n";
or die "\nCan't prepare SQL statement: \n$DBI::errstr\n\n${SQL}\n";
$sth->execute($objid) #--- Execute the SQL statement
or die "Can't execute SQL statement: $DBI::errstr\n";
or die "Can't execute SQL statement: $DBI::errstr\n";
my
$file_source = $sth->fetchrow_array();
print
"Content-Type: ${mime_type}; \n";
print "Content-Disposition: inline; filename=\"${file_name}\"\n";
print "Pragma: no-cache\n\n";
print $file_source;
}
print "Content-Disposition: inline; filename=\"${file_name}\"\n";
print "Pragma: no-cache\n\n";
print $file_source;
}
_______________________________________________ Perl-Unix-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs