Node.js / Expressasynchronousfile upload

我已经浏览了大量的(大多数是过时的)旧的堆栈溢出和谷歌的答案,并找不到与最新版本的Node和Express一起工作的该死的东西。

什么是目前的asynchronousfile upload插件?

编辑:我正在上传文件到我的Node.js服务器。 它正在运行Express。 它应该能够处理任何文件types。

我使用强大的file upload。 您可以将它们存储在目录中,也可以使用Amazon S3将它们存储在其服务器上。 它像一个魅力。

以下是一些代码的样子:

// At the top of your modules var formidable = require('formidable'); var form = new formidable.IncomingForm(); //Receive form form.parse(req, function(err, fields, files) { //Parse form and data // Do form stuff, you can access the files }); 

用jQuery,你可以做到以下几点:

  $('#your_form').on('submit', function(e) { var formData = new FormData($(this)[0]); $.ajax({ url : '/your/url/', type: 'POST', contentType: 'multipart/form-data', data: formData, success: function (msg) { console.log(msg); }, processData: false }); e.preventDefault(); });