How can i use the value of a variable i created inside the template node

[
    {
        "id": "6459ddaad53aced2",
        "type": "ui_template",
        "z": "c4c2c6195e5e2f0a",
        "g": "91c080c74028ae64",
        "group": "ba4cd6c4f1b1c4ad",
        "name": "",
        "order": 5,
        "width": 0,
        "height": 0,
        "format": " <!DOCTYPE html>\n\n<html>\n<head>\n  <title>Read File</title>\n</head>\n\n<body>\n<!-- <input type=\"file\" webkitdirectory directory multiple id=\"myFile\">\n  <button type=\"submit\" onclick=\"uploadfile()\">\n        Click to send the files\n    </button>-->\n        <input type=\"file\" id=\"myFile\" webkitdirectory directory multiple onchange=\"uploadfile()\">\n    <br><br><br>\n    <md-button ng-click=\"send({input:action()})\">\n        Click to send the files\n    </md-button>\n  <hr>\n  <textarea style=\"width:500px;height: 400px\" id=\"output\"></textarea>\n\n  <script>\n \n function uploadfile(){\n        var output = document.getElementById(\"output\");\n        let files = document.querySelector('input[type=file]').files;\n        var listsize = files.length;\n        console.log(files);\n        var chunk_size = 2000;\n        var contentarray = [];\n        //var offset = 0;\n        \n        \n        var fullsize = 0;\n        var c = 0 ;\n        while(c < listsize){\n            fullsize += files[c].size;\n            c += 1;\n        }\n        var comp = 0;\n        while(comp < listsize){\n            \n         //   console.log(files[comp]);\n         var offset = 0;\n        if (files[comp].size > 0) {\n            \n        var myFile = files[comp];\n        var size = myFile.size; //getting the file size so that we can use it for loop statement\n        var i=0;\n        console.log(\"file size \",size);\n        while( i<size){\n        var reader = new FileReader();\n        var blob = myFile.slice(offset, offset + chunk_size); //slice the file by specifying the index(chunk size)\n        var s = 0;\n        //console.log(blob);\n        reader.addEventListener('load', function (e) {\n          \n               res += btoa(e.target.result);//concatenate the output on each iteration.\n               s += e.loaded;\n              // console.log(\"s======\",s);\n              // console.log(\"////////////////////////////////////////////////\",fullsize - s == fullsize - myFile.size);\n            if (s % 2000 != 0){\n               // console.log(\"hi\");\n              //  console.log(s);\n                res += btoa(e.target.result);\n                contentarray.push(res);\n                s = 0;\n                res = '';\n                //console.log(contentarray);\n           }\n            \n           \n     //   console.log(offset);\n           \n        //   console.log(res);\n        });\n        reader.readAsBinaryString(blob);\n        offset += chunk_size; // Increment the index position(chunk) \n        i += chunk_size;\n     // Keeping track of when to exit, by incrementing till we reach file size(end of file).\n        }\n       \n      }\n      // res = res.replace('undefined','');\n        reader.addEventListener('loadend',function (e) {\n           //res = res.replace('undefined','');\n          console.log(contentarray);\n        });\n         console.log(\"*****************************************************************\",comp);\n        comp ++;\n        var res='';\n       \n        }\n    // msg.content = contentarray;\n }\n\n\n  </script>\n</body>\n</html>\n  \n",
        "storeOutMessages": true,
        "fwdInMessages": true,
        "resendOnRefresh": false,
        "templateScope": "local",
        "className": "",
        "x": 300,
        "y": 300,
        "wires": [
            [
                "ae07764595b20bdf"
            ]
        ]
    },
    {
        "id": "ba4cd6c4f1b1c4ad",
        "type": "ui_group",
        "name": "Default",
        "tab": "8e403f6af717befd",
        "order": 1,
        "disp": true,
        "width": 20,
        "collapse": false,
        "className": ""
    },
    {
        "id": "8e403f6af717befd",
        "type": "ui_tab",
        "name": "Home",
        "icon": "dashboard",
        "order": 1,
        "disabled": false,
        "hidden": false
    }
]

here is my code if it helps, i want to return the value of the content array to the next node