FormEx Property

 Object: SoftArtisans.FileUp
 Syntax: FormEx (["formelementname"])
 Type: String or file object, depending on file contents
 Read/Write: Read/Write
 Description: This retrieves the value of the specified form element. It returns form values in the same format as the ASP Request.Form object including sub-collections for multi-select items.

Prior to V2.2 of SA-FileUp, if a form element contained a multi-select list (<SELECT MULTIPLE>) or checkboxes, it was not possible to iterate over the sub-collection of form variables. As of V2.2, it is possible using ASP standard Request.Form("multisel").Count syntax, as well as by another iterator. See the example below.

FormEx has been added in addition to the existing SA-FileUp Form property so it would not break existing ASP code based upon older versions of SA-FileUp. Both Form and FormEx refer to the same underlying collection and can be used interchangeably for non-multiselect collections. If you are writing new ASP code, use FormEx for maximum compatibility with ASP's Request.Form object.

If the form element is a file, it will return the location of the file on the server (see the ServerName property).

There is still one major 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, SA-FileUp does not place the entire contents of files into memory. In summary, FileUp.FormEx will not return the unparsed data.

SA-FileUp Version 3.0- 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

 

Previous Page Next Page