TransferFile Method

Object: SoftArtisans.FileUp
Syntax: TransferFile([in] Filename As String)
Description:

This method transfers (downloads) a file from the web server's hard disk to the browser. What differentiates this functionality from a simple GET request is that TransferFile takes a physical path for the file location, allowing files to be kept in a non-browsable location.

The filename must contain the entire valid path. You can use Server.MapPath to map virtual roots to physical directories, if necessary; However, regardless of the path used, you must still have appropriate NTFS permissions for FileUp to retrieve the file from its location. Please see the section appropriate to your programming language in the Configuration and Application Settings section of this documentation set.

Typically, in addition to using TransferFile, you would also set the appropriate Response headers to inform the browser how to handle the incoming file. For a detailed tutorial and complete code sample on using the TransferFile method, please see the "Getting Started" section appropriate to your programming language:


Note on browser compatibility:

Different versions of various browsers may interpret download information differently. The following is a list of known behavior that you should be careful to test for.

  • Internet Explorer 4 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 4, you must "fool" it with a bogus extension at the end of your URL.

    http://myserver/mydownload.asp?bogus=filename.ext or
    http://myserver/mydocgenerator.asp?bogus=file.doc

  • Internet Explorer for Mac may interpret the Response headers incorrectly and provide the name of the download script in the SaveAs dialog box instead of the file name. You will need to instruct users to Save the file with the correct name if this occurs.

  • Internet Explorer for Windows version 5.5, SP1 contained the same problem as mentioned above for Internet Explorer for Mac. This was correct in a subsequent service pack and in later releases of IE.

  • For the most current and complete list of known browser issues, please check the SoftArtisans Knowledge Baseon a regular basis.
Examples:
ASP <%
fileDownload.TransferFile "C:\MyServerDir\sample.doc"
%>
C# fileDownload.TransferFile(@"C:\MyServerDir\sample.doc");
VB.NET fileDownload.TransferFile("C:\MyServerDir\sample.doc")

For a complete sample, see:

Copyright © 2010 SoftArtisans, Inc. All rights reserved.