FormEx Property


 Object: SoftArtisans.FileUp
 Syntax: FormEx (["formelementname"])
 Type: String or file object, depending on file contents
 Read/Write: Read/Write
 Description: This property retrieves the values of collections. It returns a collection. To access the elements of a FormEx collection, use either:

  • A "For...Each" statement. For example: "For each item in upl.FormEx(multipart)"

    OR

  • Index numbers. For example: "FormEx("name").index"
If the form element is a file, FormEx will return the location of the file on the server (see the ServerName property).

There is a difference between the FileUp FormEx object and the ASP Request.Form: It is possible to retrieve the raw unparsed form by specifying Request.Form without any parameters. This is acceptable when the form is small, such as less than 100 KB. However, in the case of file uploads, the potential size of the data is very large. By design, FileUp does not place the entire contents of files into memory. In summary, FileUp.FormEx will not return the unparsed data.

FileUp allows uploads into memory. See the UseMemory Property.

If you require access to the unparsed data, it is possible to use the SaveBinaryAs method and then read back appropriate sections using SA-FileManager.

Example:

<%
'---
'--- To iterate through the collection of all multiselect form elements
'---
For Each multiPart in upl.FormEx

	'-- When using FormEx, everything is a collection
	Response.Write("<BR><BR>Field: " & multipart )

	'--- This is the standard ASP way: use .Count
	For i = 1 to upl.FormEx(multipart).Count
		Selection = upl.FormEx(multipart)(i)
		Response.write("<BR>Using .Count ")
		Response.write( i & ": " & selection ) 
	next

	'--- For symmetry, we also support iterating over the sub-collection
	i = 1
	For Each Selection in upl.FormEx(multipart)
		Response.Write("<BR>Using subcollection ")
		Response.Write( i & ": " & Selection ) 
		i = i + 1
	Next


	'--- Iterate through collection and see if there
	'--- is a File object in it.
	i = 1
	For Each element in upl.FormEx(multipart)

		'--- If the element is an object then 
		'--- it is an SAFile object
		If IsObject( element ) Then
			If element.IsEmpty Then
				Response.Write("<BR><BR>File " &  element.Name & " is empty.")
			Else
				element.SaveAs("Filetest" & i & ".tst")
				Response.Write("<BR><BR>File " &  element.Name & " saved.")
			End If 
		End If
		i = i + 1
	Next

Next

 


Copyright © 2004 SoftArtisans, Inc. All rights reserved.