Skip to content

Instantly share code, notes, and snippets.

@madeinfree
Created October 25, 2017 09:42
Show Gist options
  • Save madeinfree/9b9c92ae499ac13a06588075becc11ca to your computer and use it in GitHub Desktop.
Save madeinfree/9b9c92ae499ac13a06588075becc11ca to your computer and use it in GitHub Desktop.
app.post('/audio-upload', (req, res) => {
var form = new formidable.IncomingForm();
form.uploadDir = './audio'; //set upload directory
form.keepExtensions = true;
form.type = true;
form.parse(req, function(err, fields, files) {
console.log(files);
});
form.on('file', function(field, file) {
require('fs').rename(
file.path,
require('path').join(form.uploadDir, 'myAudio.ogg')
);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment