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
|