uploadFile
Saves a Base64 encoded file to the default upload folder or to a known folder.
The default upload folder is UploadEBS, unless configured differently in the Web.config file (<add key="UploadFolder" value="~/Uploads" />).
Syntax
Copy
function uploadFile(options : IEbsUploadFileOptions, base64FileContent : string): any;
| Parameter | Type | Description |
|---|---|---|
options
|
IEbsUploadFileOptions | Name and location of the file to be uploaded. |
base64FileContent
|
string | Contents of the file encoded using the Base64 scheme. |
Type Aliases
Name and location of the file to be uploaded.
Copy
{
fileName : string;
uploadLocation? : any;
}
| Property | Type | Description |
|---|---|---|
fileName
|
string | Name of the file that will be uploaded, including the file extension. |
uploadLocation (optional) |
any | Name of the known folder:
|
Return Value
Returns a JSON object detailing the file upload with the following structure:
Copy
{
"Name": "backup.pdf",
"RealName": "backup_65d697c9-ab55-4737-a720-79c031867cc1.pdf",
"IsSuccess": true,
"Message": null,
"ClientScript": null,
"Serialized": null,
"ErrorCode": 0,
"UIResult": null
}
Examples
In this example:
- We make a backup of the contract_df7022c8-4fb3-4353-9fa8-bb2514e3a6ea.pdf file. For information on how to get the Base64 encoded contents of a file, see downloadFile.
- We save the backup in a file called backup.pdf.
- We store the upload details in a variable called upload.
- If the upload is successful, we display a success notification. For details on how to display notifications, see setMessage.
- If the upload fails, we display a failure alert. For details on how to display alerts, see setMessage.
Copy
var upload = uploadFile('backup.pdf', downloadFile('contract_df7022c8-4fb3-4353-9fa8-bb2514e3a6ea.pdf'));
if (upload.IsSuccess) {
setMessage(upload.Name + ' successfuly saved.', true);
}
else {
setMessage('Upload failed.', false);
}
In this example:
- We make a backup of the Contract_b81ea359-55d6-494d-8bd0-95788170ffde.pdf file. For information on how to get the Base64 encoded contents of a file, see downloadFile.
- We save the backup in a file called contractBackup.pdf in the Processed known folder.
- We store the upload details in a variable called upload.
- If the upload is successful, we display a success notification. For details on how to display notifications, see setMessage.
- If the upload fails, we display a failure alert. For details on how to display alerts, see setMessage.
Copy
var upload = uploadFile({fileName:'contractBackup.pdf', uploadLocation:'Processed'}, downloadFile('Contract_b81ea359-55d6-494d-8bd0-95788170ffde.pdf'));
if (upload.IsSuccess) {
setMessage(upload.Name + ' successfuly saved.', true);
}
else {
setMessage('Upload failed.', false);
}