#!/usr/bin/perl -T # # CGI.pm toy to test Mituc's and Mishoo's concerns about "save as..." ;-) # # altblue 2006-10-04 use warnings; use strict; use CGI::Pretty qw/:standard/; use URI::Escape qw(uri_escape_utf8); my $q = CGI::Pretty->new(); my %o = ( t => 'text/html', n => 'foobar.txt', d => 'inline', # or "attachment" %{ $q->Vars }, ); $o{n} = uri_escape_utf8($o{n}); print header( -type => "$o{t}; name=$o{n}", -content_disposition => "$o{d}; filename=$o{n}", -content_transfer_encoding => 'binary', -charset => 'UTF-8', ), start_html( -title => $o{n}, -encoding => 'UTF-8' ), h1( $q->escapeHTML( $o{n} ) ), p( 'localtime: ', scalar localtime ), p( 'i see you as: ', $q->remote_host ), p, start_form, label({ -for => 'n' }, 'file name'), textfield(-name => 'n', -value => $o{n}, -id => 'n' ), br, label({ -for => 't' }, 'content type'), textfield(-name => 't', -value => $o{t}, -id => 't' ), br, label({ -for => 'd' }, 'content disposition'), popup_menu(-name => 'd', -value => $o{d}, -id => 'd', -values => [qw(inline attachment)] ), br, submit, end_form, end_html;