Type Default Value Read Only Description
Long N/A Yes A set of matching fields from the upload. This is the default property of the XForm object.

 

   
Notes
 
     

The Item property contains a collection of matching fields from the current upload. The precise behavior of the Item property is complicated but all that is normally required is that you copy what you would normally do using a standard Request.Form object.

The Item property allows you to access both form input fields and file upload fields. However for ease of use you will normally use the Files collection for accessing file upload fields.

You must not refer to the Request.Form object on any page which uses an XForm object. If you do so an error will result as both try to obtain exclusive access to shared resources.

Getting the Text of a Field

If you want to get the content of a particular field you might use code like this.

Set theForm = Server.CreateObject("ABCUpload4.XForm")
Response.Write theForm("flavor")

Given the following form.

<form method="post" action="myup.asp" enctype="multipart/form-data">
<input type="text" name="flavor" value="chocolate"><br>
<input type="submit" name="submit" value="submit">
</form>

This might produce the following output.

chocolate

Getting an XField object for a Field

The normal behavior of the XForm object is identical to that of the standard Form.Request object. This means that text is the normal return value. For file upload fields you will want to reference an XField object. To do this use code like this.

Set theForm = Server.CreateObject("ABCUpload4.XForm")
Set theField = theForm("myupload")(1) ' see note below
Response.Write "File Name = " & theField.FileName & "<br>"
Response.Write "File Type = " & theField.FileType & "<br>"

Given the following form.

<form method="post" action="myup.asp" enctype="multipart/form-data">
<input type="file" name="myupload"><br>
<input type="submit" name="submit" value="submit">
</form>

This might produce the following output.

File Name = mypic.jpg
File Type = jpg

Note that when you request the object you must specify both the name of the field ("myupload") and also the index of the field (1). The index will always be one unless there are two or more identically named fields. If you do not specify an index or do not use the keyword Set the content of the file will be returned as a text string - probably not what you want.

Getting the Text of Fields with the Same Name

If you have multiple fields with the same name (something that is common if you are using checkboxes) you may want to iterate through all the boxes which were checked. You might want to use code like this.

For i = 1 To Request.Form("color").Count
  Response.Write Request.Form("color")(i) & "<br>"
Next

Given the following form.

<form method="post" action="myup.asp" enctype="multipart/form-data">
<input type="checkbox" name="color" value="red" checked>Red<br>
<input type="checkbox" name="color" value="purple" checked>Purple<br>
<input type="checkbox" name="color" value="green" checked>Green<br>
<input type="checkbox" name="color" value="blue" checked>Blue<br>
<input type="submit" name="submit" value="submit">
</form>

This might produce the following output.

red
purple
green
blue

Getting the Text of all Fields

If you want to return the contents of every field in a form you might use the following code.

Set theForm = Server.CreateObject("ABCUpload4.XForm")
For Each theItem In theForm
  Response.Write "<br>" & theItem & "<br>"
  For Each theSubitem In theForm(theItem)
    Response.Write " - " & theSubitem
  Next
Next

Given the following form.

<form method="post" action="myup.asp" enctype="multipart/form-data">
<input type="text" name="flavor" value="chocolate"><br>
<input type="checkbox" name="color" value="red" checked>Red<br>
<input type="checkbox" name="color" value="purple" checked>Purple<br>
<input type="checkbox" name="color" value="green" checked>Green<br>
<input type="checkbox" name="color" value="blue" checked>Blue<br>
<input type="submit" name="submit" value="submit">
</form>

This might produce the following output.

flavor
- chocolate
color
- red - purple - green - blue
submit
- submit

Full Description

The precise behavior of the Item property is complicated but for completeness is documented here. To understand it fully you must bear in mind that each form may be associated with many field names and each field name may be associated with many fields (though normally forms contain a unique name for each field).

If you do not pass an index the Item property returns a collection of all the field names available. This is a collection of Strings. If you pass in a String the Item property returns a collection of all fields with that name. This is a collection of XField objects. If you pass in a Number the Item property returns a collection of all fields with that index. Again this is a collection of XField objects.

The collection of XField objects also implements an Item property with an optional index parameter. A form may contain many fields with the same name so this index allows you to choose the one you are interested in. If you do not specify an index the property returns a comma delimited string of the contents of all the matching fields.

 

   
See Also
 
     

Count property. XField object.