Home     Products      Support      Corporate     Sign In 
Support Knowledge Base, Article 8
Product
FileUp
Version
2.x - 5.x
Title
Cached files do not end up in location set by Path property
Problem

One of the most common sources of confusion with FileUp is the use of the Path property. Often, code like this does not work as expected:

fileUpload.Path = "c:\mypath\" & fileUpload.Form("Userpath")

Rather than placing the temporary file in the specified directory, it ends up in
%systemroot%\system32.

Solution

When using FileUp in .NET with the HTTPModule (available in v5 and above) or the ISAPI filter (available in v4), the Path property has no effect on the upload cache location. Instead, the IsapiTempDir or FileUpTempDir registry key is used to determine the cache location. These keys are located at HKEY_LOCAL_MACHINE\SOFTWARE\Software Artisans\SA-FileUp\Parameters.

When using FileUp in ASP, the Path propery must be set before referencing any variables on the form. As soon as a form element is referenced, FileUp will read in the entire contents of the HTTP Post, including all form elements and files. It then caches the uploaded files to disk.

The above ASP example does not work because fileUpload.Form is executed before assigning the value to the Path property. By the time the Path property is set, all of the Form data will have been read, and the cache files will be created, rendering the assignment of the Path meaningless.

Instead of the above, it is recommended to set the Path to a hardcoded location and then save the file with a full pathname, i.e.

fileUpload.Path = "C:\MyPath"
fileUpload.SaveAs "C:\MyPath\" + fileUpload.Form("Userpath") + "\" + filename
Created : 1/2/2007 12:23:05 PM (last modified : 2/26/2007 4:38:43 PM)
Rate this article!
Comments