Upload File
Table of Contents
Overview
This JS API task updates a file to a File upload, Image, Audio, Video, or Signature field of a specific record, in a Zoho Creator application. The upload operation will be subject to the custom data validations configured for the corresponding form.
This V2 task is based on the Upload File REST API V2.1.
Request Details
Syntax
ZOHO.CREATOR.FILE.uploadFile(config).then(function(response){
//callback block
});
Syntax Details
The syntax holds:
- <config> (object) - The configuration required to upload a file to a specific record of a report. This configuration includes the following parameters.
Name | Type | Description |
app_name (Optional) | string | Link name of the application to which a file has to be uploaded. Retrieve the link name using the Creator form's URL: https://creatorapp.zoho.com/<account_name>/<app_name>/#Form:<form_name> Note: This parameter has to be passed only when you need to push data into other applications of the same Creator account. When not specified, data will be pushed to current application. |
report_name | string | Link name of the report whose record needs to be updated. Retrieve the link name using the Creator report's URL: https://creatorapp.zoho.com/<account_name>/<app_name>/#Report:<report_name> |
id | string | The ID of the target record that you want to upload the file to. |
field_name | string | The link name of the target field to which the file needs to be uploaded. The field link names can be found in the field properties pane of each field in the form builder. Note: If the target field (field inside subform) is situated inside a subform field (field in main form), the field_name will be <targetfield_link_name.subformfield_link_name>. |
parent_id (Optional) | string | If the target field is situated inside a subform, then the parent_id is the ID value of the parent record. This means the main form's record in which the subform has been embedded. |
file | object | It is a javascript file object to be uploaded. |
skip_workflow (Optional) | list | Prevents the associated workflows from being executed when the file is uploaded to a record. Note: By default:
|
File Size Limits
- The Image and Signature fields can accept an image that doesn't exceed 10 MB.
- The File upload, Audio, and Video fields can accept a file that doesn't exceed 50 MB.
- The file you upload will be counted towards the file storage limit of the account in which the target application exists. Visit the account's Billing page to view its current storage details.
Possible Errors
Refer to this page for the complete list of error codes and messages.
Sample Input
Copiedvar fileObject = document.getElementById("fileInput").files[0];
var config = {
app_name: "zylker",
report_name: "All-Timesheet",
id : "2000000193171",
field_name : "Attachments",
file : fileObject
};
ZOHO.CREATOR.FILE.uploadFile(config).then(function (response) {
console.log(response);
});
Sample Response
Copiedresponse = {
"code": 3000,
"data": {
"filename": "Rental Agreement-March.pdf",
"filepath": "1587402896598_Rental_Agreement-March.pdf",
"message": "success"
}
}