Files Collection (Dundas Upload Control 2.0)

Dundas

Files Collection (Dundas Upload Control 2.0)

Overview | Properties | Methods

The Files collection stores UploadedFile objects which are a result of files uploaded to the server.

Remarks

The Files collection stores one (1) UploadedFile object for every file uploaded to the server as a result of file input inboxes (e.g. <input type="file" name="File1>) in a Form. The Form must POST to the ASP page which uses the Files collection, and the ENCTYPE of the form must be "Multipart/Form-Data".

This collection is zero-based.

You MUST CALL one of the following methods to populate the Files collection: the Save method of either the Upload object or a NextFile object; or the SaveToMemory method of either an Upload object or a NextFile object. Please note that using the NextFile object's Save or SaveToMemory methods will populate the Files collection one file at a time, unlike the Upload control's save methods which populates the Files collection with one method call.

Loop through this collection when you want to utilize the uploaded files (e.g. as Attachment objects for the Mailer control). You can use the Count property of the collection as the upper loop delimiter with a standard For loop, or alternatively you can iterate through the collection by using a For Each loop.

See Also: UploadedFile Object | NextFile Object | Tutorial 1: Uploading Multiple Files and Using the Form and Files Collections | Tutorial 3: ADO Support and Saving a File as a BLOB

Example

Assumptions

  • Instances of the Upload and Mailer controls have been created.

  • Another html or ASP page has POSTED files to the page which contains this code via file input boxes in a form, with an ENCTYPE of "Multipart/Form-Data".

  • The uploaded files will be used as email attachments.

' we will loop through all UploadedFile objects and use them ' as email attachments.

For Each Item in objUpload.Files
'note that we are using the OriginalPath property of the UploadedFile objects as the

' ContentName property of the Attachment objects (ContentName will be the filename

' displayed in the client's email software). If we do not do this then the filename

' that the uploaded file was saved under will be used instead (all uploaded files

' are automatically saved with a GUID preceding the original filename).

objMailer.Attachments.Add Item.Path, Item.OriginalPath
Next