TagName (UploadedFile, NextFile and FormItem Objects)

Dundas

TagName (UploadedFile, NextFile and FormItem Objects)

Overview | Properties | Methods

Read-only property which stores the name of the form's file input box from which the uploaded file originated.

Syntax

[string] = Object.TagName

The TagName property syntax has the following parts:

Part

Description

string

The name of the form's file input box from which the uploaded file originated.

Remarks

To use the Files collection (which stores UploadedFile objects) you must first call either the Save or SaveToMemory methods. To use a NextFile object you must first call the GetNextFile method.

This property is extremely useful if you want users to upload a particular file type for a specific file input box. Examine the uploaded file's content type, and if the content type for a particular file input box is not correct you can take action accordingly. This is especially useful if you are retrieving uploaded files one at a time via the GetNextFile method (using NextFile objects) since this method gives you the option of not allowing the upload of a file to occur (only headers are retrieved with the GetNextFile method).

Refer to the source code below for further illustration on how to ensure that a file is a certain type for a given file input box.

See Also: ContentType

Example

'this sample code will assume there a file input box inside a POST form ' (with an EncType of "Multipart/Form-Data"). The name of the file input
' box is "Audio", and we will perform type checking to make sure that

' the user actually uploaded a valid audio file to the server from this input box

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

'now lets loop through the uploaded files
For Each
Item in objUpload.Files
'we will check to see which file input element is responsible for the uploaded file

If
(Item.TagName = "Audio") Then
'we now know the file came from the Audio file input box, but lets make sure

' that the user actually uploaded some sort of audio file
If
InStr(1,Item.ContentType,"audio") Then
'the file is actually an audio type

Response.Write "The uploaded file is a valid audio file."
End If

End If

Next

'release resources
Set
objUpload = Nothing