File upload: create directory if it doesnt exist
I´m handling file uploads in NodeJS with formidable. This works for me. Now I want to structure the uploads a little more. I´m passing a field from angular with my uploads, which is a project_id . I want to create a folder in my uploads, named by this ID and write the files in it. So I check if the directory exists, if not I create it with fs.mkdir and then write the files to it. Trying this, I get a EINVAL, rename error and a HTTP 500 status code. This is my attempt, anybody got an idea how to fix this? app.post('/uploads/', function(req, res, next){ var form = new formidable.IncomingForm();