Skip to content

Instantly share code, notes, and snippets.

@dibikhin
Last active January 31, 2016 22:40
Show Gist options
  • Save dibikhin/6dfac8f40814c5ccee22 to your computer and use it in GitHub Desktop.
Save dibikhin/6dfac8f40814c5ccee22 to your computer and use it in GitHub Desktop.
// Read to end first, then solve one by one.
var express = require('express');
// #0. Load 'multer' here.
// #1. Use 'uploads' folder for multer's upload here.
var app = express();
// #6. Tune Express to serve static files from '/unloads' folder.
// #7. Choose a file in 'uploads', copy it's name, navigate to http://localhost:3000/uploads/chosen_file_name
// #5. Fix the line below to receive a sigle file from field named 'avatar' and
// look at the terminal.
app.post('/profile', upload.any(), function (req, res, next) {
// #2.a Add code here to return received file's info as JSON back to the client.
// #2.b Log file's info to the console here.
// #3.a Start the server in one terminal: npm start
// #3.b Run in another terminal to test posting data:
// curl -v --form "[email protected]" http://127.0.0.1:3000/profile
// #3.c Read messages in the console in the server's terminal.
// #4. Post a file with the form in index.html
})
app.listen(3000, function () {
console.log('Your file app is listening on port 3000!');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment