Greetings Snaps_Provolone,

I read somewhere, I think maybe in the GD::Graph or Spreadsheet::WriteExcel documentation, that it can be done by controlling the CGI header. The examples given in this documentation are similar to:

print "Content-type: application/vnd.ms-excel\n"; print "Content-Disposition: attachment; filename=yourfile.xls\n"; print "\n";

Of course, if you're doing anything with CGI, you should definately use the CGI.pm module. In this case, you might try:

#!/usr/bin/perl -w use strict; use CGI; my $query = new CGI; print $query->header( -type => 'application/vnd.ms-excel', -content_disposition => 'attachment; filename=yourfile.xls' ); binmode STDOUT;

Oh, and that reminds me: that last line is important. Switch to binmode before you print your binary data to the browser.

BTW, what sort of binary data are you trying to send to the user's browser?

-gryphon
code('Perl') || die;

UPDATE: After re-reading your post, I realize now that I'm not exactly answering your question. Sorry. However, let me point out that if you have your script load and print the binary file to the browser rather than redirecting the user, you can more easily control the user experience. A redirect will show the user where you are housing the file(s) s/he wants. I don't know if this is a concern or not, but anyway...


In reply to Re: Processing HTTP file transfers by gryphon
in thread Processing HTTP file transfers by Snaps_Provolone

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.