A Simple Download


The Simple Download example shows you how to script a single-file download from a Web server to a browser. Note: FileUpEE does not support multiple-file downloads.

We will use an HTML form to submit the download request. The form contains two text boxes. In the first text box, the user will enter the server path of the file to download. In the second text box, the user will enter the download's destination path and file name.

In the server response script, the following lines get the requested file and download it to the browser:

  • Set objFileUpEE = Server.CreateObject("SoftArtisans.FileUpEE")
    Creates an instance of FileUpEE.

  • objFileUpEE.ProcessRequest Request
    Passes the Request object to FileUpEE.

  • Set File = objFileUpEE.AddDownloadFile(objFileUpEE.Form("ServerFilePath"),_
                     objFileUpEE.Form("ClientFilePath"), "file", True)

    Sets a file to download. AddDownloadFile's last parameter must be set to True in a Web-server-to-browser download. If this parameter is set to False, FileUpEE will understand that the download is from a file server to a Web server to a browser.

  • Response.ContentType = File.ContentType
    Sets the content type response header to the file's MIME content type.

  • File.WriteToResponse Response
    Sends the response - that is, downloads the file - to the browser. An open-or-save dialog will open in the browser.

To let the browser know how to handle a download, set the content-type response header to the file's ContentType before sending the file to the browser.

Example
Download a File

[View Source]

To run the example:

  1. Click the link Run sample.


  2. In the first text box, enter the path and name of the file to download.


  3. In the second text box, enter the destination path and file name.


  4. Click Download File.


Top


Copyright © 2003, SoftArtisans, Inc.