in reply to Processing HTTP file transfers

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...

Replies are listed 'Best First'.
Re: Re: Processing HTTP file transfers
by Snaps_Provolone (Novice) on Apr 22, 2002 at 22:15 UTC
    To make my posting a bit clearer, yes I do want to hide the files true source from the client. The files are ZIP files. Basically it's trying to keep people from linking directly my files. I don't think that I need the extra security of session ID's, just a simple referrer check would probably suffice to keep my files from being linked all over the web. If you want to see what I am doing currently - peek at http://www.clan-originalsin.com/files/cgi-bin/files/os-files.pl?ViewStart=0&ViewCat=4&B1=View