fsmla3 has asked for the wisdom of the Perl Monks concerning the following question:

I'm using the following to generate the header for sending the user the standard File Download dialog...
print $query->header(-type=>'application/octet-stream' -attachment=>'requested_data.zip');
It worked fine before I switched everything to mod_perl. Now it works for the most part, but on the initial dialog it uses the name of the script (e.g. 'download.pl') as the name of the file to be downloaded. Later, when the user is presented the browse dialog to save the file, the default save name is correct (in the above example 'requested_data.zip'), but I'd rather not have users freaking out because they think they're downloading something else.

Am I doing something silly?

Replies are listed 'Best First'.
Re: mod_perl download header
by Corion (Patriarch) on Oct 06, 2001 at 02:20 UTC

    In principle, this is right. I use the following to pre-specify an alternate filename (playlist.m3u in my special case) :

    print $req->header( -type=>'audio/playlist', -Content_Disposition => 'attachment;filename=playl +ist.m3u');

    There is no real standard, but the MIME headers seem to be the de facto industry standard ...


    perl -MHTTP::Daemon -MHTTP::Response -MLWP::Simple -e ' ; # The $d = new HTTP::Daemon and fork and getprint $d->url and exit;#spider ($c = $d->accept())->get_request(); $c->send_response( new #in the HTTP::Response(200,$_,$_,qq(Just another Perl hacker\n))); ' # web