v9.1p_2015-09-16/Pro Development
When using a DynamicForm with a FileItem how does one obtain the size of the selected file before starting the uploading to the server?
When using a DynamicForm with a FileItem how does one obtain the size of the selected file before starting the uploading to the server?
Code:
<DataSource
ID="fileUploadDataSource"
serverConstructor="smartclient.ds.UploadFileDataSource">
<fields>
<field name="id" type="sequence" title="ID" primaryKey="true"/>
<!-- max size is 10MB = 10485760 bytes -->
<field name="file" type="binary" title="File" maxFileSize="10485760"/>
</fields>
</DataSource>
fileUploadForm = isc.DynamicForm.create({
ID: "fileUploadForm",
dataSource: "fileUploadDataSource",
encoding: "multipart",
fields: [{
name: "file",
type: "FileItem",
dataSource: "fileUploadDataSource",
title: "uploadFileLabel"),
width: 450,
required: true,
multiple: false,
}, {
title: "uploadFileButton",
type: "button",
click: function () {
// Code to get file size and stop upload if size is 0 or too large.
fileUploadForm.saveData(function(dsResponse, data, dsRequest) {
// code for callback
}, {willHandleError: true, showPrompt: true});
}
}
]
});
Comment