Hi,
I have some content stored within a database, which I want to be saved as a
file on the user's system when requested. Currently, I generate a temporary
file (timestamp_fileid.tex) and use a cron job to clean up the directory every
30 minutes:
if ($texcontent) {
my $texfile = texer($texcontent, $id);
print qq{<a class="image" href="../tmp/$texfile" target="_self"><img
src="../gifs/latex.jpeg" alt="latex_version" width="70" height="37" border="0"
/></a>};
}
sub texer {
my ($texcontent, $page_id) = @_;
my ($page_id_safe) = $page_id =~ /(.+)/;
my $filename = time . "_$page_id_safe.tex";
chdir "../tmp";
open (FILE, "> $filename") or die "Cannot open file for writing: $!";
print FILE $texcontent;
close (FILE);
chdir "../cgi-bin";
return $filename;
}
How can I make the user's browser
a) save the file instead of just printing its content to the screen (as with
the header text/plain), so I do not need to use a temporary file
b) use a certain filename when saving the file instead of displaying a saving
dialog?
Thanks,
Jan
--
Imagine if every Thursday your shoes exploded if you tied them the usual way.
This happens to us all the time with computers, and nobody thinks of
complaining. - Jeff Raskin
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>