Home     Products      Support      Corporate     Sign In 
Support Knowledge Base, Article 1292
Product
XFile
Version
Up to 2.4.1
Title
When using XFile to perform upload and download, the response may be empty
Problem

Many applications allow users to upload and download files. For efficiency and convenience, the same instance of XFile can be used to perform both uploading and dowloading. When XFile performs an upload, the server response is accessible in the Response property of the XFRequest object. However, if the user performs a download before an upload, the Response property may be empty.

Solution

This issue occurs only if the same instance of XFile is used to perform both uploading and downloading.

The XFRequest object has 2 similar but mutually exclusive properties, Response and ResponseFile. Both store the server response. ResponseFile is simply a path where the response is saved. When uploading, XFile saves the server response in the Response property. When downloading, the response is the content of the file, so ResponseFile is set to the path of the downloaded file. For further details, refer to the documentation pages for Response and ResponseFile.

The problem is that after a download, the ResponseFile property is not reset. So for any subsequent upload, the server response will still go to the location specified by ResponseFile. This will overwrite the previous download, so it's quite a serious problem. The other side-effect is that the Response property will be empty and thus not displayed by the browser; this is usually the first symptom that alerts users to the problem.

We will resolve this issue in a future release of XFile. Fortunately, there are 2 simple workarounds, as follows:

  1. Create separate instances of the XFRequest object to handle uploads and downloads:
    [Javascript] [VBScript]  
    var XFileUpload = new ActiveXObject("SoftArtisans.XFRequest");
    var XFileDownload = new ActiveXObject("SoftArtisans.XFRequest");
                    
  2. Manually reset the ResponseFile property to an empty string before each upload:
    XFRequest.ResponseFile = "";
    

Created : 7/27/2009 6:29:09 PM (last modified : 2/28/2011 3:47:45 PM)
Rate this article!
 
Comments