I've pawed through numerous (and mostly outdated) older stack overflow and Google answers and can't find a damn thing that works with the latest versions of Node and Express.
What is the current go-to plugin for async file uploads?
EDIT: I'm uploading the files to my Node.js server. It's running Express. It should be able to handle any file types.
I use formidable for file uploads. You can either store them inside of a directory or you can use Amazon S3 to store them on their servers. It works like a charm.
Here is what some code looks like:
// 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
});
With jQuery, you can do the following:
$('#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);
},
contentType: false,
processData: false
});
e.preventDefault();
});