# Dashboard button to start file download

**URL:** https://discourse.nodered.org/t/dashboard-button-to-start-file-download/43614
**Category:** Dashboard
**Created:** [3 April 2021 18:11 UTC](https://discourse.nodered.org/t/dashboard-button-to-start-file-download/43614 "2021-04-03T18:11:55Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![davidz](https://avatars.discourse-cdn.com/v4/letter/d/a88e57/32.png) [@davidz](https://discourse.nodered.org/u/davidz)
#### Post date: [3 April 2021 18:11 UTC](https://discourse.nodered.org/t/dashboard-button-to-start-file-download/43614/1 "2021-04-03T18:11:55Z")

</div>

First, the file can be downloaded via a template node form submission. So file download is not the problem.

But how to link the dashboard button to file download? That is: If a person clicks the download button, the the file will be downloaded. I know this might be simple but I can't fine an answer 😅

The following is the flow:

```auto
[{"id":"6f7ed72f.4ba6b8","type":"debug","z":"c37fcc5b.b6edb","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":910,"y":840,"wires":[]},{"id":"8a4440e7.4e8e7","type":"http in","z":"c37fcc5b.b6edb","name":"","url":"/data.csv","method":"get","upload":false,"swaggerDoc":"","x":590,"y":900,"wires":[["4fa2d392.0122bc"]]},{"id":"4fa2d392.0122bc","type":"file in","z":"c37fcc5b.b6edb","name":"","filename":"/home/pi/.node-red/public/data.csv","format":"","sendError":true,"x":880,"y":900,"wires":[["d659f021.5555f8"]]},{"id":"d659f021.5555f8","type":"http response","z":"c37fcc5b.b6edb","name":"","statusCode":"","headers":{},"x":1110,"y":900,"wires":[]},{"id":"f97e6e7e.09b18","type":"ui_button","z":"c37fcc5b.b6edb","name":"","group":"c4536f8a.ffdf5","order":2,"width":0,"height":0,"passthru":false,"label":"Download data","tooltip":"","color":"","bgcolor":"","icon":"","payload":"<a href=\"/data.csv\">","payloadType":"str","topic":"","topicType":"str","x":530,"y":840,"wires":[["d62d8837.b25338"]]},{"id":"d62d8837.b25338","type":"ui_template","z":"c37fcc5b.b6edb","group":"c4536f8a.ffdf5","name":"","order":16,"width":0,"height":0,"format":"<script>\n(function(scope) {\n scope.$watch('msg', function(msg) {\n if (msg) \n {\n\n // what will be the code here?\n \n \n }\n });\n})(scope);\n</script>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","x":720,"y":840,"wires":[["6f7ed72f.4ba6b8"]]},{"id":"c4536f8a.ffdf5","type":"ui_group","name":"Data Export","tab":"71b53261.d60bec","order":2,"disp":true,"width":"12"},{"id":"71b53261.d60bec","type":"ui_tab","name":"Broadcasting temperature","icon":"dashboard","order":2,"disabled":false,"hidden":false}]

```

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [3 April 2021 19:24 UTC](https://discourse.nodered.org/t/dashboard-button-to-start-file-download/43614/2 "2021-04-03T19:24:26Z")

</div>

The dashboard button node is designed to send the payload back to node red. if you want to initiate a download you will have to use a template and your own button or a hyperlink.

---

<div class="post-metadata">

### Author: ![davidz](https://avatars.discourse-cdn.com/v4/letter/d/a88e57/32.png) [@davidz](https://discourse.nodered.org/u/davidz)
#### Post date: [3 April 2021 21:17 UTC](https://discourse.nodered.org/t/dashboard-button-to-start-file-download/43614/3 "2021-04-03T21:17:59Z")

</div>

I know how to use a template with a button inside the template, or a hyperlink to download the file.

I just don't like the look of the button inside the template, which is not consistent with Dashboard's button.

So there is no easy way to initiate the download from a Dashboard button? 😂

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [3 April 2021 21:22 UTC](https://discourse.nodered.org/t/dashboard-button-to-start-file-download/43614/4 "2021-04-03T21:22:43Z")

</div>

> [@davidz](#):
>
> So there is no easy way to initiate the download from a Dashboard button?

No. It is designed to send a Payload to the server side.

Well, as it's web, anything is possible so you could use a script to hook the click event but that's a hack

The answer is to style the button you put in the template the same as the UI button.

Look at the styles that get applied in devtools

---

<div class="post-metadata">

### Author: ![davidz](https://avatars.discourse-cdn.com/v4/letter/d/a88e57/32.png) [@davidz](https://discourse.nodered.org/u/davidz)
#### Post date: [3 April 2021 21:26 UTC](https://discourse.nodered.org/t/dashboard-button-to-start-file-download/43614/5 "2021-04-03T21:26:56Z")

</div>

Thanks Steve. I will look into it.  
I am not familiar with button style inside template node 😅

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [3 April 2021 21:28 UTC](https://discourse.nodered.org/t/dashboard-button-to-start-file-download/43614/6 "2021-04-03T21:28:45Z")

</div>

try these...

```auto
<button class="md-raised md-button md-ink-ripple" type="button">template button</button>

<md-button>template md-button</button>

```

---

<div class="post-metadata">

### Author: ![davidz](https://avatars.discourse-cdn.com/v4/letter/d/a88e57/32.png) [@davidz](https://discourse.nodered.org/u/davidz)
#### Post date: [3 April 2021 21:40 UTC](https://discourse.nodered.org/t/dashboard-button-to-start-file-download/43614/7 "2021-04-03T21:40:56Z")

</div>

Thanks and I will try it out.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [3 May 2021 21:41 UTC](https://discourse.nodered.org/t/dashboard-button-to-start-file-download/43614/8 "2021-05-03T21:41:11Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
