SaveAs (Dundas Upload Control 2.0)

Dundas

SaveAs (UploadedFile Object)

Call this method to save an uploaded file in memory to disk.

Syntax

UploadedFileObject.SaveAs (Path As String)

The SaveAs method syntax has the following part(s):

Part

Description

Path

The full pathname (i.e. path and filename) of the file's destination. If UseVirtualDir has been set to TRUE then this argument must also use a virtual directory.

  Remarks

To utilize this method the file must have been saved to memory using the SaveToMemory method. An exception will be thrown if the file in question was not saved to memory. An exception will also be raised if you call this method twice for the same file.

If you have set the UseVirtualDir property to TRUE then the Path argument must also use a virtual directory. The syntax for the Path argument would then be: "/VirtualDir/AnyOtherDirs/FileName".

When calling this method you must specify the directory and filename for the desired destination (e.g. "e:\temp\myfile.txt"). To save the file to a directory using the original filename (i.e. the filename at the client) you can use the Upload control's GetFileName method, using the UploadedFile object's OriginalPath property as the argument. See the sample source code below for an illustration of this.

See Also: Save | SaveToMemory

Example

'we will assume that the Files collection has been populated using the Upload
' control's SaveToMemory method.

'
'this sample code saves the files in memory to a directory named "temp",

' using the file's original names (at the client)

'create instance of control
Set
objUpload = Server.CreateObject("Dundas.Upload.2")

'populate collections and retrieve all uploaded form data (including
' uploaded files)

objUpload.SaveToMemory

'loop through all uploaded files and save each file to the "temp"
' directory, using their original filenames

For
Each objUploadedFile in objUpload.Files
objUploadedFile.SaveAs "c:\temp\" & objUpload.GetFileName(objUploadedFile.OriginalPath)
Next

'release resources
Set
objUpload = Nothing