node.js file upload Error: ENOENT, rename ' tmp/xxxxxx.jpeg', think the fault is in my path, what am I doing wrong?

1.1k views Asked by At

My code looks like this:

enter image description here

and the terminal output looks like this: enter image description here

But I dont want the path to be under "routes". But rather under bears/public/...

Appreciate any help!

1

There are 1 answers

2
chrisbajorin On BEST ANSWER

In your current setup, you're just joining the path as a string. This doesn't allow you to move up levels within your folder structure.

var path = require("path")

var target_path = path.join(__dirname, "../public/images/bjornar")

The path module will join them as if you were moving around in command line.