Biferno 1.7 Tabasoft.it

Application: ItaliaScuola Back-Office3
Reference
Admin | Edit | Reference | Cache | Logs
Click on a class name to see the description of that particular class:

Predefined Classes

ansi
array
biferno
boolean
cacheItem
char
classInfo
client
collection
curApp
curFile
curScript
db
double
error
file
folder
header
httpPage
imageUtils
int
long
memberInfo
multipart
object
ref
regexp
request
search
serverInfo
smtp
stackItem
string
time
unix
unsigned
 

Application Classes

Banner
BrowserBar
Ctrl_Form
FCKeditor
Form
GridChartGraph
Histogram
LocalDate
Result
condb
cookie
folderExt
headerExt
httpExt
mysqlFulltext
objHtml
requestExt
tableExport
utils
 

Functions

Functions

multipart

Method:

ToFile

void ToFile(string path, boolean overwrite)

Write on disk a multipart object

Description:

This method stores the content of a multipart object in a file specified by "path"

Parameters:
path

specifies the path of the file to be stored. If path points to a folder, the property name of the multipart is automatically added to the path

overwrite

if a file in the "path" location already exists and this parameter is true it is overwritten. if a file in the "path" location already exists and this parameter is false an error is throwed

Notes:

The following script provides an example of management of the information concerning the file sent by the form.

<html>
<body>
<?
file_name = ValueOf("the_file.name")
if (file_name)
{
?>
	The file $file_name$ was sent.<br>
	The file size is $the_file.data.length$   byte<p>
<?
	// Store file on server
	new_path = "/upload/" + file_name
	the_file.ToFile(new_path)
}
else
{
?>
	No file was sent.
<?
}
?>
</body>
</html>

The conditional statement verifies that a file has been effectively uploaded in the input field. Because the the_file variable of the multipart class associated to the form is always defined, the test checks that the name property of the variable does not contain an empty string.

If the the_file variable contains data, the name and size (in bytes) of the corresponding file are printed. Then, the file is stored in a directory called “upload” located in the server root (or more precisely in the site root) using the method ToFile. The use of this method makes it easy to store on the server files submitted by users via HTML forms.

Notice that, even though in the example above the file has been stored on the server using the same file name, any new name can be specified for the new file.

Implementation:
C
 

Return to the multipart class