Slip 9 - A) Create a Node,js file that writes an HTML form, with an upload field.

Solution:

upload.js


var http = require('http');

http.createServer(function (req, res) {

  res.writeHead(200, {'Content-Type': 'text/html'});

  res.write('<form action="fileupload" method="post" enctype="multipart/form-data">');

  res.write('<input type="file" name="filetoupload"><br>');

  res.write('<input type="submit">');

  res.write('</form>');

  return res.end();

}).listen(8080);

 

Initiate upload.js file :

C:\Users\Your Name>node upload.js

Post a Comment

0 Comments