Upload file to SQL table

Here is something to get you moving...

chrome_hthbhteUbQ

[{"id":"5c4ecf7618af2177","type":"debug","z":"a1cabb2f724b8139","name":"After DropDown Selec ","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":2084,"y":192,"wires":[]},{"id":"8ee5e87a1115812c","type":"ui_dropdown","z":"a1cabb2f724b8139","name":"","label":"Which ID?","tooltip":"","place":"Select option","group":"05b42c30b8013f8b","order":1,"width":6,"height":1,"passthru":false,"multiple":false,"options":[{"label":"1","value":"1","type":"str"},{"label":"2","value":"2","type":"str"},{"label":"3","value":"3","type":"str"}],"payload":"","topic":"topic","topicType":"msg","className":"","x":1882,"y":128,"wires":[["933f9a058b233007"]]},{"id":"f4f79f36f3fdf902","type":"ui_template","z":"a1cabb2f724b8139","group":"05b42c30b8013f8b","name":"Upload Button","order":2,"width":4,"height":1,"format":"<body>\n    <md-button ng-click=\"importData()\">\n       Upload Image\n    </md-button>\n    <script>\n        (function (scope) {\n            scope.importData = function importData() {\n                let input = document.createElement('input');\n                input.type = 'file';\n                input.accept = \".png,.jpg,.pdf\";\n                // input.id = 'restoreBtn';\n                input.onchange = _ => {\n                    let fReader = new FileReader();\n                    fReader.readAsArrayBuffer(input.files[0]);\n                    fReader.onloadend = function (event) {\n                        scope.send({ payload: event.target.result });\n                    }\n                };\n                input.click();\n            }\n        })(scope);\n    </script>\n</body>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":false,"templateScope":"local","className":"","x":1200,"y":368,"wires":[["339871aa9d5ab2f8"]]},{"id":"5bae79c4d3d0316f","type":"debug","z":"a1cabb2f724b8139","name":"IDAllegato","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"IDAllegato","targetType":"msg","statusVal":"IDAllegato","statusType":"auto","x":1898,"y":416,"wires":[]},{"id":"933f9a058b233007","type":"change","z":"a1cabb2f724b8139","name":"","rules":[{"t":"set","p":"IDAllegato","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":2074,"y":128,"wires":[["5c4ecf7618af2177"]]},{"id":"d86ae2e813952b59","type":"change","z":"a1cabb2f724b8139","name":"","rules":[{"t":"set","p":"IDAllegato","pt":"msg","to":"IDAllegato","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":1706,"y":368,"wires":[["5bae79c4d3d0316f","32de08937192d4a5","4639059b01e5ec76"]]},{"id":"32de08937192d4a5","type":"debug","z":"a1cabb2f724b8139","name":"image data","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"IDAllegato","statusType":"auto","x":1898,"y":464,"wires":[]},{"id":"7788e77555c3a835","type":"switch","z":"a1cabb2f724b8139","name":"","property":"IDAllegato","propertyType":"flow","rules":[{"t":"btwn","v":"1","vt":"num","v2":"3","v2t":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":1522,"y":368,"wires":[["d86ae2e813952b59","8aa952dd8ca31c5e"],["0277072197f3cc1a"]]},{"id":"44f849df7615b454","type":"ui_toast","z":"a1cabb2f724b8139","position":"top right","displayTime":"3","highlight":"red","sendall":true,"outputs":0,"ok":"OK","cancel":"","raw":false,"className":"error","topic":"Error","name":"ID not set","x":1648,"y":448,"wires":[]},{"id":"61f455b743a2ea00","type":"ui_ui_control","z":"a1cabb2f724b8139","name":"On connect","events":"connect","x":1294,"y":220,"wires":[["ebf775cb43daa270"]]},{"id":"8d7c0e25d1c834d8","type":"change","z":"a1cabb2f724b8139","name":"init to 1","rules":[{"t":"set","p":"IDAllegato","pt":"flow","to":"1","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":1740,"y":224,"wires":[["8ee5e87a1115812c"]]},{"id":"ebf775cb43daa270","type":"switch","z":"a1cabb2f724b8139","name":"IDAllegato between 1 ~ 3 ?","property":"IDAllegato","propertyType":"flow","rules":[{"t":"btwn","v":"1","vt":"num","v2":"3","v2t":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":1528,"y":208,"wires":[["8ee5e87a1115812c"],["8d7c0e25d1c834d8"]]},{"id":"91dbfd46b95945d0","type":"inject","z":"a1cabb2f724b8139","name":"on NR start","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1294,"y":180,"wires":[["ebf775cb43daa270"]]},{"id":"b8cc93035869acb3","type":"inject","z":"a1cabb2f724b8139","name":"unset ID","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"0","payloadType":"num","x":1284,"y":128,"wires":[["8345eb0597a8d5c9"]]},{"id":"8345eb0597a8d5c9","type":"change","z":"a1cabb2f724b8139","name":"","rules":[{"t":"set","p":"IDAllegato","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1466,"y":128,"wires":[["8ee5e87a1115812c"]]},{"id":"ada1a832d3c3c341","type":"ui_toast","z":"a1cabb2f724b8139","position":"top right","displayTime":"3","highlight":"green","sendall":true,"outputs":0,"ok":"OK","cancel":"","raw":false,"className":"success","topic":"Success","name":"success","x":2312,"y":432,"wires":[]},{"id":"4639059b01e5ec76","type":"function","z":"a1cabb2f724b8139","name":"Replace me with SQL node","func":"\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1956,"y":368,"wires":[["81a6cc333bb90328"]]},{"id":"81a6cc333bb90328","type":"switch","z":"a1cabb2f724b8139","name":"Check SQL error?","property":"error","propertyType":"msg","rules":[{"t":"nnull"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":2202,"y":368,"wires":[["5a9da1134623f070"],["d2b749efe131d721"]]},{"id":"0277072197f3cc1a","type":"change","z":"a1cabb2f724b8139","name":"ID not set","rules":[{"t":"set","p":"payload","pt":"msg","to":"ID not set","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1504,"y":448,"wires":[["44f849df7615b454"]]},{"id":"89eee5f0cfe824a6","type":"ui_toast","z":"a1cabb2f724b8139","position":"top right","displayTime":"3","highlight":"red","sendall":true,"outputs":0,"ok":"OK","cancel":"","raw":false,"className":"error","topic":"Error","name":"ID not set","x":2308,"y":320,"wires":[]},{"id":"5a9da1134623f070","type":"change","z":"a1cabb2f724b8139","name":"SQL Error","rules":[{"t":"set","p":"payload","pt":"msg","to":"SQL Error","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":2172,"y":320,"wires":[["89eee5f0cfe824a6"]]},{"id":"d2b749efe131d721","type":"change","z":"a1cabb2f724b8139","name":"Done OK","rules":[{"t":"set","p":"payload","pt":"msg","to":"Data Upload Complete","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":2176,"y":432,"wires":[["ada1a832d3c3c341"]]},{"id":"339871aa9d5ab2f8","type":"jimp-image","z":"a1cabb2f724b8139","name":"make tumbnail","data":"payload","dataType":"msg","ret":"b64","parameter1":"","parameter1Type":"auto","parameter2":"120","parameter2Type":"num","parameter3":"RESIZE_NEAREST_NEIGHBOR","parameter3Type":"resizeMode","parameter4":"","parameter4Type":"msg","parameter5":"","parameter5Type":"msg","parameter6":"","parameter6Type":"msg","parameter7":"","parameter7Type":"msg","parameter8":"","parameter8Type":"msg","sendProperty":"payload","sendPropertyType":"msg","parameterCount":3,"jimpFunction":"resize","selectedJimpFunction":{"name":"resize","fn":"resize","description":"resize the image. One of the w or h parameters can be set to automatic (\"Jimp.AUTO\" or -1).","parameters":[{"name":"w","type":"num|auto","required":true,"hint":"the width to resize the image to (or \"Jimp.AUTO\" or -1)"},{"name":"h","type":"num|auto","required":true,"hint":"the height to resize the image to (or \"Jimp.AUTO\" or -1)"},{"name":"mode","type":"resizeMode","required":false,"hint":"a scaling method (e.g. Jimp.RESIZE_BEZIER)"}]},"x":1376,"y":368,"wires":[["7788e77555c3a835"]]},{"id":"7903c1513bfdede4","type":"ui_template","z":"a1cabb2f724b8139","group":"05b42c30b8013f8b","name":"the image","order":3,"width":10,"height":7,"format":"<style>\n    div.img-container {\n        height: 250px\n    }\n    div.img-container > img {\n        width: 100%;\n        max-height: 100%\n    }\n</style>    \n\n<div class=\"img-container\" ng-bind-html=\"msg.payload\"></div>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":false,"templateScope":"local","className":"","x":1820,"y":320,"wires":[[]]},{"id":"8aa952dd8ca31c5e","type":"template","z":"a1cabb2f724b8139","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<img src=\"{{{payload}}}\">","output":"str","x":1676,"y":320,"wires":[["7903c1513bfdede4"]]},{"id":"05b42c30b8013f8b","type":"ui_group","name":"Carica Certificato Taratura","tab":"21286fd2ee7bdc0c","order":5,"disp":true,"width":"10","collapse":false,"className":""},{"id":"21286fd2ee7bdc0c","type":"ui_tab","name":"test-tab","icon":"assignment","order":5,"disabled":false,"hidden":false}]

NOTE

Requires node-red-contril-image-tools node to be installed.