Save an uploaded file in other path

I'am using template node and i want to move an uploaded file to another destination path .. i have tried with this node https://flows.nodered.org/node/node-red-contrib-fs-ops
but i have to put the original path of the file and it seems to be impossible to get the source path for security reason.

Any ideas ! and thank you.

If you have uploaded a file's contents into Node-RED you can save it using the file-out node.

Thanks for replying. How can i send the content of uploded file ??

take a look at the output file node and it’s info panel

ok thnks a lot

Search file here

Plenty of examples.

One thing that's not clear to mind. You say "move an uploaded file"

If you have the file in node red already, just use file out node to write it to your required location.

If you actually want to just move a file, then perhaps use an exec node and use an operating system call like move (sorry don't know what os you're on)

1 Like

thanks a lot. it really helped.

i have uploaded pdf file and i use file out to write it to the new destination.
i have used most the encoding type but with no result !!!!
what should i have to do ?

What do you mean by "I have uploaded"?

Do you have the contents of pdf file as a buffer within the Node-RED flow?
How did you get it there?

How have you configured the message to the file out node?

The text box "filename" expects a file name (e.g. c:/temp/upload.pdf") not a variable.

If you are trying to save a file to the value of msg.fileDirectoty then you'll need to do this...

  1. Remove "msg.fileDirectoty" from the file node. (Filename field should be left blank as it states in the built in help info on the side panel)
  2. And a Change node (copy msg.fileDirectoty to msg.filename)
  3. Wire change node to file out node.

Notes...
fileDirectoty is an odd name. Apart from the spelling, is the value actually a directory or a full file path? For the file node, its value should be either a filename or full file path+filename.

Sorry my mistake, i mean file directory not "fileDirectoty" !! :roll_eyes:
Well my main problem is saving the content of uploaded pdf file in other directory. I have almost tried all the native encoding choices but none of them works for me !!
Am i missing something ?

so it seems you have (however it got there) the file to write in a buffer (as seen in your screen shot).

so send that buffer to a file out node with the file name required entered as text into the filename box (e.g. c:/temp/file.pdf').

If you want a dynamic file name, use a change node to include msg.filename on the message BEFORe you call the file out node
e.g.
[Node With File Data] :arrow_right: [change node (set msg.filename to msg.fileDirectoty)] :arrow_right: [file out node].

1 Like

Just re-reading this...

have you had success saving any file anywhere?



It seems from your statement (reading between the lines)...

"Well my main problem is saving the content of uploaded pdf file in other directory"

suggests you can save somewhere but not other place?




Then you say...

"I have almost tried all the native encoding choices but none of them works for me !!"

Why would you think changing encoding would help save in a different location?

Sorry again. silly me. changing encoding value is something wrong. Thanks for replying, it really helped.