Downloading EXE files from a dynamic request |
It's actually a little tricky to get this to work across all browsers, because once again IE and Netscape behave differently. Netscape tends to be safer prompting always for download while IE may immediately display certain files that are registered in the browser immediately.
To display a file name in the download dialog you need to modify the HTTP header to include a Content Disposition which is the filename. The following is a Web Connection request that picks up an EXE file from disk and sends it to the browser client application:
lcFile = FileToStr('SomeExeFile.Exe')
lcFName = 'SomeFile.exe'
loHeader = CREATE('wwHTTPHeader',Response)
loHeader.SetProtocol('HTTP/1.0 200 OK')
loHeader.AddHeader('Content-length',LTRIM(STR(LEN(lcFile))) )
loHeader.AddHeader('Content-Disposition','attachment; filename='+lcFName)
loHeader.CompleteHeader()
Response.Write(lcFile)
However, this may still cause you problems with certain file types that can be displayed directly in the browser. instead of downloading they may just run and show in the browser. With EXE files there shouldn't be a problem though, since you'll always get prompted.
Last Updated: 03/16/99