Class: SoftArtisans.FileUp
Method: TransferFile ([in] Filename)
Description: This method transfers (downloads) a file from the web server's hard disk to the browser.
The filename must contain the entire valid path. You can use Server.MapPath to map virtual roots to physical directories. See Example 2 below.
Typically, you set the Content (MIME) type before executing this method.
Special note for Internet Explorer users: IE does not recognize MIME types supplied by the web server. Unfortunately, this does not comply with the HTTP protocol. Instead, IE uses the extension found at the end of the URL to determine the MIME type. So to download to IE, you must "fool" it with a bogus extension at the end of your URL. Also, IE ignores the MIME-standard content-disposition header that allows the web developer to pre-set the filename contained the user's Save Dialog box. Perhaps with enough grassroots support, Microsoft will accept to process these standard MIME headers. An example workaround would be:
http://myserver/mydownload.asp?bogus=filename.ext
or
http://myserver/mydocgenerator.asp?bogus=file.doc
Example 1:
<%
Response.ContentType = "application/msword"
'---
'--- Instanciate the file download component
'---
Set download = Server.CreateObject("SoftArtisans.FileUp")
'---
'--- Do the transfer. There is only one parameter: the local webserver
'--- filename. It can be any valid filename (UNICODE ok), as long as
'--- the IUSR_<machinename> account has read access.
'---
download.TransferFile "c:\myserverdir\sample.doc"
... %>
Example 2:
<% download.TransferFile server.mappath("sample.doc") %>