Petras has asked for the wisdom of the Perl Monks concerning the following question:
The following code will print an HTML "just in case" page:# code ripped from perlmonks.org/index.pl?node_id=9277 chdir($filepath) || die "Unable to chdir to filepath"; my $filesize = -s $filename; # print full header print "Content-disposition: attatchment; filename=$filename\n"; print "Content-Length: $filesize\n"; print "Content-Type: application/x-tar\n\n"; # open in binmode open(READ,$filename) || die; binmode READ; # stream it out binmode STDOUT; while (<READ>) { print; } close(READ);
So the question finally is: How can a script be written to send a file and print an HTML page (or vice versa), or more basically, can a single script send two types of Content-Types or headers?my $q = CGI -> new(); print $q -> header( "text/html" ), $q -> start_html (-title => "File Download", -bgcolor => "#ffffcc" ), $q -> p ( "If the file does not begin to dowload automatically i +t can be downloaded <a href=\"$filepath$filename\">here</a>." ), $q -> p ( "<a href=../foo.html>Back to foo</a>"), $q -> p ( "<a href=../index.html>Bar Home</a>"), $q -> end_html;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Sending Multiple Content-Types
by aquarium (Curate) on Jun 20, 2003 at 14:28 UTC | |
by Petras (Friar) on Jun 26, 2003 at 17:26 UTC | |
|
Re: Sending Multiple Content-Types
by fglock (Vicar) on Jun 20, 2003 at 14:38 UTC | |
by Petras (Friar) on Jun 28, 2003 at 00:51 UTC |