Search code examples
node.jsdir

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


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!


Solution

  • 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.