# Write file to a local disk drive

**URL:** <https://discourse.nodered.org/t/write-file-to-a-local-disk-drive/90101>\
**Category:** General\
**Created:** [11 August 2024 02:45 UTC](https://discourse.nodered.org/t/write-file-to-a-local-disk-drive/90101 "2024-08-11T02:45:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![bachphi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bachphi/32/104849_2.png) [@bachphi](https://discourse.nodered.org/u/bachphi)\
**Post date:** [11 August 2024 02:45 UTC](https://discourse.nodered.org/t/write-file-to-a-local-disk-drive/90101/1 "2024-08-11T02:45:55Z")

</div>

I am injecting a simple 'Hello' string into a file and want to save the file to my local PC. However, since Node-RED is running on a server, all attempts have resulted in the file being written to the server instead. Is it possible to write the file directly to my local machine?

```auto
[
    {
        "id": "8a6ba7b298a5a932",
        "type": "inject",
        "z": "e309c37c879f6a3a",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "Hello, World!",
        "payloadType": "str",
        "x": 190,
        "y": 120,
        "wires": [
            [
                "7827ee46592af7da"
            ]
        ]
    },
    {
        "id": "7827ee46592af7da",
        "type": "file",
        "z": "e309c37c879f6a3a",
        "name": "",
        "filename": "file://C:/Temp/Hello.txt",
        "filenameType": "str",
        "appendNewline": false,
        "createDir": true,
        "overwriteFile": "true",
        "encoding": "none",
        "x": 440,
        "y": 120,
        "wires": [
            [
                "c8afd54ae18fe26b"
            ]
        ]
    },
    {
        "id": "7ab566b3ccbbbe4b",
        "type": "debug",
        "z": "e309c37c879f6a3a",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 970,
        "y": 140,
        "wires": []
    },
    {
        "id": "c8afd54ae18fe26b",
        "type": "file in",
        "z": "e309c37c879f6a3a",
        "name": "",
        "filename": "file://C:/Temp/Hello.txt",
        "filenameType": "str",
        "format": "utf8",
        "chunk": false,
        "sendError": false,
        "encoding": "none",
        "allProps": false,
        "x": 700,
        "y": 120,
        "wires": [
            [
                "7ab566b3ccbbbe4b"
            ]
        ]
    }
]

```

---

<div class="post-metadata">

**Author:** ![Bobo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bobo/32/8401_2.png) [@Bobo](https://discourse.nodered.org/u/Bobo)\
**Post date:** [11 August 2024 04:28 UTC](https://discourse.nodered.org/t/write-file-to-a-local-disk-drive/90101/2 "2024-08-11T04:28:22Z")

</div>

One way (and the way I often use) is to use SCP (secure copy protocol) inside an Exec node.

I suggest you do a little research on SCP first (eg [What is SCP Protocol? A Complete Guide](https://blog.invgate.com/what-is-scp-protocol-a-complete-guide)) to see if it suits your needs.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [11 August 2024 08:10 UTC](https://discourse.nodered.org/t/write-file-to-a-local-disk-drive/90101/3 "2024-08-11T08:10:44Z")

</div>

> [@bachphi](#):
>
> want to save the file to my local PC

That is the process of Downloading a file from the server to the PC running the browser. I have not done this myself, but If you search the forum for Download File I expect it will produce a number of possibilities.

---

<div class="post-metadata">

**Author:** ![HaroldPetersInskipp](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/haroldpetersinskipp/32/42319_2.png) [@HaroldPetersInskipp](https://discourse.nodered.org/u/HaroldPetersInskipp)\
**Post date:** [11 August 2024 23:24 UTC](https://discourse.nodered.org/t/write-file-to-a-local-disk-drive/90101/4 "2024-08-11T23:24:19Z")

</div>

The node `@prescient-devices/node-red-contrib-downloadfile` can accomplish what you desire. You can find it [here](https://flows.nodered.org/node/@prescient-devices/node-red-contrib-downloadfile).

---

<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:** [9 November 2024 23:24 UTC](https://discourse.nodered.org/t/write-file-to-a-local-disk-drive/90101/5 "2024-11-09T23:24:39Z")

</div>

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