I am trying to just do a simple file upload with formidable in node js, and with this code: `
app.post("/upld", function(req, res){
var form = new formidable.IncomingForm();
form.parse(req, function (err, fields, files) {
var oldpath = files.filetoupload.filepath;
var newpath = 'uploads/' + files.filetoupload.newFilename;
fs.rename(__dirname + oldpath, __dirname + "/" + newpath, function (err) {
if (err) throw err;
res.write('File uploaded');
res.end();
});
});
});
and here is the html form:
<body>
<form action="upld" method="post" enctype="multipart/form-data">
<input type="file" name="filetoupload"><br>
<input type="submit">
</form>
</body>
</html>
I get an error saying that there is no file or directory named "tmp/9885a1a737766e7a6963b6a00" I know that that temp folder will change everytime, that is just the most recent attempted one.
I have tried looking at the file data by sending it through the response, but all of the information there checks out. How can I access the uploaded file from its temp folder?