Home     Products      Support      Corporate     Sign In 
Support Knowledge Base, Article 806
Product
FileUp
Title
Can I use FileUp to access the uploaded files without ever writing them to disk?
Problem
You may want access to the files that are being uploaded, but prefer to not cache or save the files to disk. This article will demonstrate how this can be done using the UploadContents and UseMemory properties.
Solution

FileUp can be instructed to cache the upload to memory instead of to disk, using the UseMemory property of the FileUp object*. From there, the uploaded files can be accessed through the UploadContents property of the File object. The UploadContents property can return the file contents as a string, an array of variants or an array of binary characters. The example below uses FileUp to cache the upload to memory, access the uploaded file contents as a string and write the contents of the string back to the browser in the HTTP Response:

<%
 '--- Declarations
 Dim oFileUp

 '--- Instantiate the FileUp object
 Set oFileUp = Server.CreateObject("SoftArtisans.FileUp")
 oFileUp.UseMemory = true

 '--- Check to be sure there was a file selected in the form
 '--- If so, continue processing
 If Not oFileUp.Form("myFile").IsEmpty Then

    Dim myString
    myString = oFileUp.Form("myFile").uploadContents(0)'--returns string

    '--- The file is saved, display a confirmation message
    Response.Write myString

 Else
    Response.Write("Error: There was no file submitted for upload.")
 End If

 '--- Destroy objects
 Set oFileUp = Nothing
%>

*UseMemory has no effect when used in conjunction with FileUp's httpModule or ISAPI filter. For further information, see the link below for the UseMemory property.


Related Links
Created : 2/24/2004 10:19:14 AM (last modified : 2/24/2004 10:19:14 AM)
Rate this article!
Comments