Node.Js fs module in Multer for automatic folder creation

Node.Js fs module in Multer for automatic folder creation

Hey Guys ??,

So let's make our code easier to run and functional for practical use cases. When we use multer npm package to upload multipart form data in our express app. In that situation, we have to create a folder like uploads in our working directory before uploading any file. If we don't create a folder before uploading then it shows like this below:-

To Solve this issue we can use Node JS build-in file system ( fs ) module. Simply

add this code in multer.diskStorage where we set the destination of our files.

Here, if we don't have a folder on our server, it will automatically create one for our files.


I hope you learn from these small tips.

Cheers,

Monib Bormon ??

要查看或添加评论,请登录

Monib Bormon的更多文章

  • NPM full form is not Node Package Manager ?

    NPM full form is not Node Package Manager ?

    Are you shocked? Are you thinking Am I gone mad? ?? Yes, you will be shocked after hearing that NPM does not stand for…

    1 条评论

社区洞察

其他会员也浏览了