in reply to Re^2: CGI outputs plain text -- can't "Save Page As?"
in thread CGI outputs plain text -- can't "Save Page As?"
1. does not re-upload a file on a reload (my mozilla seamonkey/iceape 1.0.8 DOES re-upload on reload).
2. does a new GET request for the result page when you try to save it. (of course, that means you get a blank page - except that you're printing an extra blank line in convert_word2.cgi). (mozilla does the same).
Here's the script I used to test that. Note that if you outcomment the "Content-Disposition" line, firefox will request you to save the output directly, which fixes the bug, in some sense.
#!/usr/bin/perl -w use strict; use CGI; my $q = CGI->new; my $method = $q->request_method; my $r = rand(1000000); my $fh = $q->upload("file"); warn "fh is ",($fh ? "" : "not "),"defined"; if ($fh) { #print "Content-Disposition: attachment; filename=output.txt\n"; print "Content-type: text/plain\n"; print "\n"; print "METHOD=$method\n"; my @data =<$fh>; warn "data = '",@data,"'"; print @data; exit; } print <<ENDHTML; Content-type: text/html <html> <body> METHOD=$method <form action="test.cgi?r=$r" method="POST" enctype="multipart/form-dat +a"> <input type="file" name="file"><input type="submit"> </form> </html> ENDHTML
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: CGI outputs plain text -- can't "Save Page As?"
by bcrowell2 (Friar) on May 28, 2007 at 02:31 UTC |