In the widget, transfer the file obtained from the client to the server

ddd
Tera Contributor

Hello
I created a widget, the screen operation I uploaded a file.

And get the file in client. I want to transfer the currently obtained file to the server side for processing.

 

Client:

entryVal[1] is a file

ddd_1-1737597647157.png

Server:Now the Server gets empty(fileData

ddd_0-1737598065115.png

 

 

 

2 REPLIES 2

Ankur Bawiskar
Tera Patron
Tera Patron

@ddd 

please share your both the scripts and not screenshots

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Client:
c.uploadAttachments2 = function() {
        document.getElementById('fileToUpload').value = '';
        $scope.files.forEach(function(file) {
            $scope.fd = new FormData();
            $scope.fd.append('files', file);
            var fdEntries = $scope.fd.entries();
            var fdEntry = fdEntries.next();
            var entryVal = fdEntry.value;
            c.server.get({
                action: 'uploadFileServer',
                caData: {
                    fileData: entryVal[1]
                }
            }).then(function(r) {
               
            });
};
Server:
if (input) {
        if (input.action == "uploadFileServer") {
            gs.info('xuexu0123===' + input.caData.fileData);
        }
}
log:
xuexu0123===[object Object]
 
Once the Server gets the file, I want to call the AttachmentAPI and upload the file