javascript - Best way to upload file using node js - Stack Overflow

what is the best way of handling file uploads using node js?I want my user to upload a profile image,

what is the best way of handling file uploads using node js? I want my user to upload a profile image, the uploader should have this functionality: -validated that the image should be at min 200 * 200 -file must be only png, jpg, jpeg or gif -and other stuff that an uploader should have (for example renaming the file before saving that and lots of other, you know) So, what package do you suggest me to use? is it better to use package or native node js?

what is the best way of handling file uploads using node js? I want my user to upload a profile image, the uploader should have this functionality: -validated that the image should be at min 200 * 200 -file must be only png, jpg, jpeg or gif -and other stuff that an uploader should have (for example renaming the file before saving that and lots of other, you know) So, what package do you suggest me to use? is it better to use package or native node js?

Share Improve this question edited Dec 31, 2016 at 18:19 Joseph asked Dec 31, 2016 at 18:16 JosephJoseph 2,0162 gold badges13 silver badges20 bronze badges 2
  • nodejs only: ponentix./blog/9/file-uploads-using-nodejs-now-for-real – user956584 Commented Apr 29, 2017 at 19:06
  • check this out, it shows how to upload binary files using multer: youtube./watch?v=d8COHTGz2cc – Inzamam Malik Commented Oct 20, 2022 at 9:22
Add a ment  | 

2 Answers 2

Reset to default 2

For handling file uploads, you need to handle the multipart/form-data which contain the file and its metadata.

You can roll your own solution by handling this part, but I suggest you to go for Multer until you really understand all the specifics as it can get quite tedious.

Multer has abstracted everything for you and gives you a very simple middleware interface to act on the form-data quite easily.

You can also look at this blog post which explains file uploading in node via multer with example: https://codeforgeek./2014/11/file-uploads-using-node-js/

If someone uses EXPRESS with NodeJS then express-fileupload is the simple and most powerful node-package to upload file(s) on the server. There you'll find all the options and steps to use this package.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745496611a4630217.html

相关推荐

  • javascript - Best way to upload file using node js - Stack Overflow

    what is the best way of handling file uploads using node js?I want my user to upload a profile image,

    1天前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信