Home     Products      Support      Corporate     Sign In 
Support Knowledge Base, Article 223
Product
XFile
Version
1.x
Title
HOW TO: Download from an ASP page using XFile and FileUp
Problem
 
XFile can download files either by requesting the desired file directly from a virtual directory on the server, or by requesting an ASP page which uses a server-side control, (such as SoftArtisans FileUp) to output the file.  An advantage of this second method is additional security.  Files to be downloaded can be stored in a location on the server which is not browsable.  Furthermore, the path of the file is not visible to the user, as it is only spelled out in the server-side code of the download processing page.
 
Solution

In order to download from an asp page to XFile, you will pass, to XFile's AddFile method, the URL of an asp download processing page, rather than the URL of the file to be downloaded. If you do not wish to hardcode which files you want to download in the server-side processing page, you can pass a querystring containing the filename in the URL of the ASP page.  Passing the filename by querystring also allows you to use one server-side asp processing page to download multiple files. 
 
The attached sample uses XFile on the client and FileUp on the server to download two files from a non-browsable directory on the server.  In order to run this sample, unzip xfile-fileupdownload.zip and please do the following:
 
Place the files AXFFile_ASPdownload.htm, AXFFileProgress.htm, and fileup_download.asp in a virtual directory on the server.
 
In the client-side script in AXFFile_ASPdownload.htm, modify the following lines:
 
AXFFileDownload.AddFile "c:\temp\file1.txt", "http://localhost/mycode/xfile-fileupdownload.asp?filename=file1.txt"
AXFFileDownload.AddFile "c:\temp\file2.doc", "http://localhost/mycode/xfile-fileupdownload.asp?filename=file2.doc"
 
For each of these AddFile lines, make sure that the second parameter contains the complete URL to the download processing page xfile-fileupdownload.asp on  your server. Leave the querystrings as they are.  If you wish to download the files to a location on the client other than "c:\temp", also modify the first parameter to spell out the complete paths for the downloaded files on the client.
 
Move the directory FilesToDownload to the root of the "C:" drive, or another location on the server.  If you do not place this directory in "C:\", then you need to modify the following line in fileup_download.asp:
 
filepath = "c:\FilesToDownload"  
 
Replace the path with the physical path of the "FilesToDownload" directory on your server.  
 
Browse the file AXFFile_ASPdownload.htm. Click the "start download" button.

Attachments
Attachments/KB223_XFile-FileUpDownload.zip
Created : 12/1/2002 12:00:00 AM (last modified : 11/9/2001 12:08:00 PM)
Rate this article!
Comments