|
The advantages of FileUpEE downloading include:
|
|
The following ASP and ASP.NET samples demonstrate downloading a single file from
web server to client. Note that the download scripts do not contain HTML or Response.Write
statements. In a download, the response should include only the downloaded file
and its response headers. HTML and Response.Write lines will corrupt
the downloaded file.
FileUpEE provides two techniques for downloading files from web server to client:
AddDownloadFile/WriteToResponse and
TransferFile. The samples above
use the AddDownloadFile/WriteToResponse to download the file sample.doc
from FileUpEE's doc-samples\samples directory.
The following VBScript lines download a file using the FileUpEE method
AddDownloadFile and the FileEE method WriteToResponse:
Set oFileUpEE = Server.CreateObject("SoftArtisans.FileUpEE")strPathToDownloadFile = Server.MapPath("/FileUpEE/Samples/sample.doc")
Set oDownFile = oFileUpEE.AddDownloadFile(strPathToDownloadFile, "docdownload.doc",
"myDownFile", True)
Adds a file to the collection of files to download. The AddDownloadFile
method returns a FileEE
object that represents the file to download. AddDownloadFile takes
four parameters:
DownloadPath |
|||
|---|---|---|---|
| The path and name of the file to download. | |||
ClientPath |
|||
| The destination name of the downloaded file. This file name will appear in the "Open or Save" dialog on the client. | |||
Name |
|||
The value of Name may be used to reference the file in script, for
example:objFileUpEE("myDownFile").ContentType = "text/plain" |
|||
WebServerDownload |
|||
To script a download from a file server to a web server to a client, set WebServerDownload
to False. To script a download from a web server to a client, set WebServerDownload
to True. |
|||
oDownFile.WriteToResponse ResponseTo ensure that the download is not corrupted by extraneous characters in the response:
Response.Write statements in the download script.
WriteToResponse, call Response.Clear to
erase any buffered HTML output.
WriteToResponse, call Response.End.
In ASP.NET, after calling WriteToResponse, call Response.Close.
The AddDownloadFile method sets content-type and content-disposition
response headers for the file to download. When using the AddDownloadFile/WriteToResponse
download method, do not set these response headers in script.
|
To download a file using the FileUpEE method
TransferFile:
TransferFile method does not set response headers for the download.
To let the browser know how to handle a download, set the content-type and content-disposition
response headers:Response.ContentType = "application/msword"
Response.AddHeader "content-disposition", "attachment;filename=""docdownload.doc"""
TransferFile to download the file from the web server to the client:strPathToDownloadFile = Server.MapPath("/FileUpEE/Samples/sample.doc")
oFileUpEE.TransferFile Request, Response, strPathToDownloadFile To ensure that the download is not corrupted by extraneous characters in the response:
Response.Write statements in the download script.
Response.Clear to erase any
buffered HTML output.
TransferFile, call Response.End.
In ASP.NET, after calling TransferFile, call Response.Close.
In ASP, Typelibs provide quick and convenient access to constants associated with
a particular object. The script in this example includes FileUpEE's TypeLib because
the script uses constants (e.g,
saWebServer). The UUID attribute specifies FileUpEE's unique
identifier.
<!--METADATA TYPE="TypeLib" UUID="{6B16F98B-015D-417C-9753-74C0404EBC37}" -->