Making a file uploader using node.js

I need to make a file uploader to make my website able to save profile pictures for its users, I tried googling how to do it but I haven`t met good resources. So i am searching for tutorials that will teach me how to save files using node js.

That’s pretty much the File Metadata Microservice. It suggest using multer, it is quite easy to use.

Can you gve me a tutorial that explains it simpler. That would realy help.


var multer = require("multer");
var upload = multer({ dest: 'uploads/' });"/upload", upload.single("upfile"), (req, res) => {
  console.log(req.file);  // check all properties available
  res.json({ msg: "hi" });


<form enctype="multipart/form-data" action="/upload" method="post">
    <input id="inputfile" type="file" name="upfile" />
    <input id="submit" type="submit" value="Upload">
1 Like

it returns undefined, i did it my way instead of single i wrote any but it doesn`t return path

at first tried this way but in uploads folder, it uploads files that can’t be the open cause of no extension name .
may be i am missing something
so i tried something like this

var storage = multer.diskStorage({
destination: function (request, file, callback) {
callback(null, __dirname+'/forum/uploads');
filename: function (request, file, callback) {
callback(null, file.originalname)

which is basically replace the file to the original name.
Now my question is, in your project, inside uploads folder is there is any extension after the uploaded file name?

btw your project is looking great :slight_smile: .

1 Like

Wil have to look that up. I didn’t run into any issues.

EDIT No they don’t have extensions.

Are you making the file metadata project or do you want to implement it somewhere else?

1 Like

I am doing the metadata project but I was just messing with the code.
at first, i did not understand the data was perfect I thought it was a corrupted data, then I understand it was not corrupted just metadata .but to be sure changed the file name.

I implemented it on a different project but i am insecure is it the right way to store profile pictures. Now i will skip the whole thing and use facebook login.