Search results

Add Additional Data on Upload in JavaScript Uploader control

02 Aug 2021 / 1 minute to read

The uploader component allows you to add additional data on file upload, which is used to get in the server-side. By using uploading event and its customFormData argument, you can achieve this behavior. Refer to the following example.

In the following code snippet, explains about how to add additional data on file upload.

Copied to clipboard
import { Uploader } from '@syncfusion/ej2-inputs';


let uploadObj: Uploader = new Uploader({
    asyncSettings: {
        saveUrl: 'https://ej2.syncfusion.com/services/api/uploadbox/Save',
        removeUrl: 'https://ej2.syncfusion.com/services/api/uploadbox/Remove'
    },
    uploading: onFileUpload

});
uploadObj.appendTo('#fileupload');

function onFileUpload(args: any) {
    // add addition data as key-value pair.
    args.customFormData = [{'name': 'Syncfusion INC'}];
}

Server side for adding additional data

Copied to clipboard
    // Get the additional data in server end by corresponding key.
    var data = HttpContext.Current.Request.Form["name"];

You can also explore JavaScript File Upload feature tour page for its groundbreaking features. You can also explore our JavaScript File Upload example to understand how to browse the files which you want to upload to the server.