UploadOptions

The UploadOptions class supplies a number of options used when a file is uploaded from a browser to a server. It is used as an argument for WebForm#uploadFileFromBrowser(UploadOptions).

The following properties are available. If a property is not specified, the corresponding system default from server properties (configured using the server administration application) is used.

  • directory - the target directory on the server (default property Ufs.fileDirectoryName)
  • maxFileSize - the maximum file size that can be uploaded (default property Ufs.maxUploadFileSize)
  • fileTypes - the file types that can be uploaded (default property Ufs.uploadFileTypes)
  • acceptedMimeTypes - the accepted MIME types - used by supporting browsers to constrain the file types shown in the browse panel (no default)
The fileTypes property is a list of file types supported by the server e.g. doc, pdf, txt etc. An error message is issued if the user attempts to upload a file with a different type.

The acceptedMimeTypes property is a list of supported MIME types and provides a way of helping the user by setting the file types in the browse panel. This is implemented using the HTML accept parameter of the input tag and the implementation of this parameter varies according to the browser, with some browsers - notably IE before version 10 - providing no support. So using MIME types can provide a way of helping some users, but it doesn't provide a way to constrain which files can be uploaded - use the fileTypes property to achieve this.

Further documentation.

Javascript examples:

 var opts1 = new UploadOptions();
 opts1.directory = "c:/temp";                 // Backslashes should be escaped e.g. c:\\temp
 form.uploadFileFromBrowser(opts1);           // Invoke the upload
  
 var opts2 = new UploadOptions();
 opts2.acceptedMimeTypes = [ "image/*" ];     // Limit the file types shown in the browser panel
 opts2.fileTypes = [ "png", "gif", "jpg" ];   // Only these file types can be uploaded
 form.uploadFileFromBrowser(opts2);           // Invoke the upload 
 

UploadOptions Functions

getAcceptedMimeTypes UploadOptions.getAcceptedMimeTypes( ) An array of accepted MIME types.
setAcceptedMimeTypes UploadOptions.setAcceptedMimeTypes( acceptedMimeTypes ) Sets the list of accepted MIME types.
getDirectory UploadOptions.getDirectory( ) The directory where uploaded files will be saved.
setDirectory UploadOptions.setDirectory( directory ) Sets the target directory on the server for uploaded files, and can be either a relative or absolute path.
getDirectoryInternal UploadOptions.getDirectoryInternal( )
getFileTypes UploadOptions.getFileTypes( ) An array of allowable case insensitive file types that can be uploaded.
setFileTypes UploadOptions.setFileTypes( fileTypes ) Sets the list of case insensitive file types that can be uploaded.
getMaxFileSize UploadOptions.getMaxFileSize( ) The maximum size of file that can be uploaded.
setMaxFileSize UploadOptions.setMaxFileSize( maxFileSize ) Sets the maximum size for an uploadable file.
getMaxFileSizeInternal UploadOptions.getMaxFileSizeInternal( )