# Advanced-ftp does not work when feeding filename and localFilename

**URL:** https://discourse.nodered.org/t/advanced-ftp-does-not-work-when-feeding-filename-and-localfilename/43416
**Category:** General
**Created:** [30 March 2021 18:47 UTC](https://discourse.nodered.org/t/advanced-ftp-does-not-work-when-feeding-filename-and-localfilename/43416 "2021-03-30T18:47:21Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![KevinPamu](https://avatars.discourse-cdn.com/v4/letter/k/ba9def/32.png) [@KevinPamu](https://discourse.nodered.org/u/KevinPamu)
#### Post date: [30 March 2021 18:47 UTC](https://discourse.nodered.org/t/advanced-ftp-does-not-work-when-feeding-filename-and-localfilename/43416/1 "2021-03-30T18:47:21Z")

</div>

Hi,

I have a flow where the advanced-ftp node works when I put in the filename and localFilename in the node.

however, I leave them blank and feed the filename and localFilename using a function node, it doesn't seem to work. I could be missing something very simple here but here is my function

`var local = msg.payload; var remote = "/site/invoices/"+msg.payload; var localn = "C:\\PosPlus\\Invoices\\Working\\"+local; msg.filename = remote; msg.localFilename = localn; return msg;`

Error: The filename, directory name, or volume label syntax is incorrect.

But when I copy the value of the msg.filename and msg.localFilename to the node itself it works.

What am I doing wrong?

Thank you in advance, Let me know if you need more information.

---

<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: [30 March 2021 19:41 UTC](https://discourse.nodered.org/t/advanced-ftp-does-not-work-when-feeding-filename-and-localfilename/43416/2 "2021-03-30T19:41:32Z")

</div>

Feed that into a debug node set to show Complete Message and check everything looks right. I suggest you use forward slashes rather that backslash, then you don't have to worry about escaping them. Forward slashes work fine in Windows.

---

<div class="post-metadata">

### Author: ![KevinPamu](https://avatars.discourse-cdn.com/v4/letter/k/ba9def/32.png) [@KevinPamu](https://discourse.nodered.org/u/KevinPamu)
#### Post date: [30 March 2021 19:45 UTC](https://discourse.nodered.org/t/advanced-ftp-does-not-work-when-feeding-filename-and-localfilename/43416/3 "2021-03-30T19:45:52Z")

</div>

`{"payload":"","topic":"","filename":"/site/invoices/Produce_Invoice_003_03192021_125956.csv\r","parts":{"index":2,"ch":"\n","type":"string","id":"d2887f53.ef9f"},"_msgid":"e0ff6a24.f0f548","localFilename":"C:/PosPlus/Invoices/Working/Produce_Invoice_003_03192021_125956.csv\r"}`

That's the complete message object. I see the /r in there do you think that's the problem?

---

<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: [30 March 2021 19:59 UTC](https://discourse.nodered.org/t/advanced-ftp-does-not-work-when-feeding-filename-and-localfilename/43416/4 "2021-03-30T19:59:44Z")

</div>

> [@KevinPamu](#):
>
> I see the /r in there do you think that's the problem

Quite possibly. If you put  
`msg.payload = msg.payload.trim()`  
at the start then I think that will remove those. Check in the debug node to see. Or do that wherever you create msg.payload earlier in the flow.

Whenever you have a problem with a node the first thing to do is to look at what you are sending it and make sure it looks right.

---

<div class="post-metadata">

### Author: ![KevinPamu](https://avatars.discourse-cdn.com/v4/letter/k/ba9def/32.png) [@KevinPamu](https://discourse.nodered.org/u/KevinPamu)
#### Post date: [30 March 2021 20:02 UTC](https://discourse.nodered.org/t/advanced-ftp-does-not-work-when-feeding-filename-and-localfilename/43416/5 "2021-03-30T20:02:49Z")

</div>

> [@Colin](#):
>
> msg.payload = msg.payload.trim()

That did it!! Thank you Colin!!

Will pay closer attention next time. 🙂

---

<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: [13 April 2021 20:02 UTC](https://discourse.nodered.org/t/advanced-ftp-does-not-work-when-feeding-filename-and-localfilename/43416/6 "2021-04-13T20:02:53Z")

</div>

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