The following script provides an example of management of the information concerning the file sent by the form.
file_name = ValueOf("the_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
No file was sent.
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.