formidable form node js
const http = require('http');const formidable = require('formidable'); const server = http.createServer((req, res) => { if (req.url === '/api/upload' && req.method.toLowerCase() === 'post') { // parse a file upload const form = formidable({ multiples: true }); form.parse(req, (err, fields, files) => { res.writeHead(200, { 'content-type': 'application/json' }); res.end(JSON.stringify({ fields, files }, null, 2)); }); return; } // show a file upload form res.writeHead(200, { 'content-type': 'text/html' }); res.end(` <h2>With Node.js <code>"http"</code> module</h2> <form action="/api/upload" enctype="multipart/form-data" method="post"> <div>Text field title: <input type="text" name="title" /></div> <div>File: <input type="file" name="multipleFiles" multiple="multiple" /></div> <input type="submit" value="Upload" /> </form> `);}); server.listen(8080, () => { console.log('Server listening on http://localhost:8080/ ...');});
Also in JavaScript:
- chart.js line chart
- sonarqube for angular application
- how to add two numbers in javascript
- find react version
- js find array return true false
- how to find the current date and time of a city in js
- Code is valid JSON equivalent of the key/value pair shown that also preserves the original value: UPC: 043875
- javascript online compiler
- 'App' is not defined react/jsx-no-undef
- casl react
- create json model online
- how to get href value of anchor tag in jquery in list
- node js express static folder
- js conditional key
- javascript xml request
- dom create element
- cordova android close app with back button
- prototype inheritance javascript
- update head tag metadata vue
- jquery wait for all ajax requests to complete
- join 2 array in javascript
- how to get the index of an array in javascript
- how to find the gradient linear of image
- multiple image upload with preview and delete react js