in reply to How to offer binary files for download via CGI ?

The sample code you've posted doesn't do anything with the file's contents; it just reads them, puts them in a variable, then returns it as the result of dl_user. Perhaps it's printed elsewhere, but if not that's part of your problem.

The usual content type for arbitrary binary data is application/octet-stream, although I don't think that's part of your current problem.

It can also be awkward to read binary files with the diamond operator <FILE>, since line breaks don't occur in any particular place. It's usually best to use read, but again I don't think this is causing the problem you're seeing.

Replies are listed 'Best First'.
Re: Re: How to offer binary files for download via CGI ?
by waswas-fng (Curate) on Jul 22, 2003 at 23:53 UTC
    <> Do the Right Thing with bin slurps -- although read is better. octet-stream seems to have some issues with random browsers showing the file instead of saving. I will have to go back and look what type i used after doing a ton of tests with many browsers -- I just hvae it stuck in my mind that octet-stream failed a bunch of download tests last time I did this.

    -Waswas