in reply to Not able to display 'save as dialog box' in browser
You can only use a single CRLF character as header separator. Here, you use two. Two CRLF character is used to separate headers from content.print "Content-Type: application/octet-stream\n\n";
After all, how can you have two Content-Type header? If what you have is a plain text file to send, you don't need that octet-stream. I think you want,
Using \n as CRLF can be problematic. It's safer to use CGI or CGI::Simple, CRLF is handled automatically.print "Content-Type: text/plain\n"; print "Content-Length: $filesize\n"; print "Content-disposition: attachment; filename=$filename\n\n"; open FILE, $filename or die "can't open $filename: $!\n"; print while <FILE>; close FILE;
use CGI::Simple; use strict; use warnings; my $cgi = CGI::Simple->new; my $filename = '/usr/local/..../file.txt'; # assumed exists print $cgi->header( -type => 'text/plain', -attachment => $filename, -content_length => -s($filename), ); open FILE, $filename or die "Can't open $filename: $!\n"; print while <FILE>;
Open source softwares? Share and enjoy. Make profit from them if you can. Yet, share and enjoy!
|
|---|