Home     Products      Support      Corporate     Sign In 
Support Knowledge Base, Article 1176
Product
XFile
Version
2.1.4
Title
Can I use XFile's graphical Progress Indicator object with the non-graphical transfer engine (XFRequest Object)?
Problem

Yes. In version 2.1.4 of XFile, the XFRequestStream property was added to the XFRequest object, thereby giving it the ability to communicate with the graphical Progress Indicator object.

Up until version 2.1.4 of XFile, you were limited to using the Progress Indicator with the graphical controls only. If you wanted to provide a progress indicator for XFile's non-graphical transfer engine, you need to use the TransferProgress events of the XFRequest object to design a visual interface to function as your own progress indicator.

The following article demonstrates how to use the Progress Indicator object with the XFRequest object. A complete code sample is attached at the bottom of the article.

Solution

To use the Progress Indicator object (AXFFileProgress object) with the non-graphical transfer engine(XFRequest object), go through the same steps as you would to use it with either of the graphical controls.

  1. Instantiate the XFRequest object in an HTML page. Provide a button from which you can launch script on the onClick event. In this script, launch a new window.
  2. In this new window, your progress indicator script will run and do the following:
    1. Instantiate the AXFFileProgress object.
    2. Link the XFRequestStream property of the AXFFileProgress object to the XFRequestStream property of the XFRequest object.
    3. Call the AXFFileProgress object's StartProgress method
    4. Call back to the Start method of XFile on the parent page to initiate the actual transfer. It is necessary to start the upload from the progress indicator page to make sure the progress indicator starts monitoring progress before the file transfer starts.

In the main page that instantiates the Transfer Engine...


 <SCRIPT language='vbs'>
 Sub UploadButton_onClick()

 ...XFile related code...

 '--- Open a window in which to run the progress indicator script

 winstyle="height=300,width=400,status=no,toolbar=no,menubar=no,location=no"

 window.open "ProgressIndicatorPage.asp",Nothing,winstyle


 ...other code, such as disabling upload button

 End Sub

</SCRIPT>

<OBJECT CLASSID="clsid:C3A57B60-C117-11D2-BD9B-00105A0A7E89"
      codebase="./SAXFile.cab#version=2,1,4,20274"
      ID="SAXFile">
</OBJECT>

In the Progress Indicator page (ProgressIndicatorPage.asp)...

  
 <HEAD>
 <SCRIPT language='vbs'>
'--- This sub is called when the page loads '--- It syncs the progress indicator with the XFile upload from the '--- other browser window Sub ShowProgressIndication() '--- Link the progress indicator to the XFile transfer
document.all("AXFFileProgress").XFRequestStream = opener.document.all ("SAXFile").XFRequestStream
'--- Show the progress

document.all("AXFFileProgress").ShowProgress
'--- Start the transfer
opener.document.all("SAXFile").Start
window.close End Sub </SCRIPT> </HEAD> <BODY onload="ShowProgressIndication()"> <OBJECT ID="AXFFileProgress" CLASSID="CLSID:C3EAF164-E06A-11D2-B5C9-0050041B7FF6" VIEWASTEXT> </OBJECT> </BODY>

The complete code on which the above sample is based is provided as an attachment to this KB article.

Note about setting up the sample:
  • Unpack the zip file to a directory that is mapped to a virtual directory in IIS.

  • The sample assumes that your client and webserver are on the same machine, and therefore uses "Server.MapPath" to locate the provided sample files, so the code can run without modification. If you are using a remote client, you will need to change the paths provided in the "AddFile" methods to files that exist on your remote client.

  • You will need to change the value for XFile's CurrentURL property to a value appropriate to your environment.

  • Likewise, be certain to set appropriate permissions on the path specified in FileUp's Path property.

  • The sample assumes that you will either place the XFile cab file in the same virtual directory as the sample script or that you will change the path to the cab file specified in the <OBJECT> tag.

  • This sample was written using properties and methods available in version 2.1.4 of XFile. If you are not using at least this version, please upgrade before attempting to run the sample.

  • You must have FileUp installed on the same webserver.

  • For the sake of making samples easy to run with the minimal amount of configuration or code unrelated to the immediate demonstration, samples may not always use "best practices". For a list of best practices to implement in production quality code, please see the following article: Index of "Best Practices" for XFile

Attachments
Attachments/KB1176_KB1176.zip
Created : 8/12/2005 2:02:55 PM (last modified : 8/12/2005 2:02:54 PM)
Rate this article!
 
Comments