Home     Products      Support      Corporate     Sign In 
Support Knowledge Base, Article 1073
Product
XFile
Version
Any
Title
FileUp does not process form elements posted by XFile
Problem
XFile is being used client side to post only form elements to the server, and the FileUp processing page on the server returns a 500 Internal Server Error response.
Solution

This is a scenario that would only occur if XFile is being used to POST form elements to the server without including any files. This sometimes occurs in applications which provide users with a web form that includes an optional upload option, so that some requests contain only form elements. In such a scenario, XFile will default to a different form encoding type than is normally used for uploads. Since there are no files, it assumes that using "application/x-www-form-urlencoded" would be more efficient, as it doesn't require MIME boundaries in the POST.

The problem with this is that FileUp on the server does not recognize that type of encoding and will fail when attempting to parse the POST. In order to send only form elements with XFile and allow FileUp to successfully parse the request, it is necessary to manually set the FormEncType property of the XFRequest object.

Code Example:


    SAXFile.RequestMethod = "POST";
    SAXFile.FormEncType = "multipart/form-data";
    SAXFile.CurrentURL = "http://[ServerName]/upload.aspx";
    SAXFile.AddFormElement("TestKey", "TestVal");
    SAXFile.Start();


Created : 1/7/2008 3:08:33 PM (last modified : 1/7/2008 3:08:33 PM)
Rate this article!
Comments