I believe I have solved the problem using the following code:

  $filereq = "myfile.exe";         #name of file you want in save as box 
  $file = "c:\\temp\\myfile.exe";  #path and name of file to send
   open (BFILE,"$file") ;
   binmode BFILE;     
   $size= -s BFILE;
   print "Content: $filereq\r\n";
   print "Content-Type: application/octet-stream\r\n";
   print "Content-Length: $size\n";
   print "Content-Disposition: attachment\; filename=$filereq\r\n\r\n";

   while(<BFILE>){
        print $_;
     }
   close BFILE;


  In reading a Microsoft TechNet article the trick is not to include the
file path in the "Content-Disposition" statement and not in quotes.




-----Original Message-----
From: Cash, Robert [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 24, 2001 2:36 PM
To: [EMAIL PROTECTED]
Subject: File Download Problem


I'm using a CGI script to control authorization to file downloads. The
script takes the users authorization from a web page, checks an authorize
file and if the details match, it delivers the requested file (which sits
outside of the web server's sphere of influence)  to the browser for
download.

Little problem - this all works fine, but the file name is not returned to
the browser's download box - if I want to download a file called "file.zip",
the download box will try to save the file as "download.pl" (which is the
post-to script's name).

Is there any way, ideally via the CGI headers, to return the filename so
that the browser tries to save the file under the correct name?

I'm currently using this for the CGI header:

print $query->header(-type=>'application/octet-stream',
                -Content-length=>$fsize,
                -nph=>1);
_______________________________________________
Perl-Win32-Web mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-web
_______________________________________________
Perl-Win32-Web mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-web

Reply via email to