Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

form-data upload file

// `form-data` library gives us a similar API in Node.js to the `FormData` interface in the browser
const FormData = require('form-data');

// Create a new form instance
const form = new FormData();

// Append text fields to the form
form.append('productName', 'Node.js Stickers');
form.append('productDescription', 'Cool collection of Node.js stickers for your laptop.');

// `file` can either be a Buffer or a Stream
// ⚠️ don't forget the 3rd argument, the file name, when appending a file
form.append('productImage', file, 'stickers.jpg');
Comment

FormData upload file

const form = document.getElementById('form');
const formData = new FormData(form);

const output = document.getElementById('output');

for (const [key, value] of formData) {
  output.textContent += `${key}: ${value}
`;
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: make an object javascript 
Javascript :: javascript async/await 
Javascript :: nextjs react native web typescript 
Javascript :: regex scan youtube video id 
Javascript :: react fragment inside map with key prop 
Javascript :: javascript objectentries 
Javascript :: multiple export in react 
Javascript :: how draw table from json ajax 
Javascript :: angular Failed to make request to https://www.gstatic.com/firebasejs/releases.json 
Javascript :: find max number in java 
Javascript :: javascript create json object from array 
Javascript :: js sleep 1 sec 
Javascript :: javascript get second last element of array 
Javascript :: javascript integer 
Javascript :: discord button 
Javascript :: input from terminal node js 
Javascript :: javascript remove first element from array 
Javascript :: javascript await return value 
Javascript :: makeStyles is not longer exported from @mui/material/styles 
Javascript :: js date subtract minutes 
Javascript :: ejs formatter vscode 
Javascript :: after effects loop wiggle 
Javascript :: nodejs heap usage 
Javascript :: multiple conditions for JavaScript .includes() method 
Javascript :: discord.js make channel private 
Javascript :: componentwillunmount hooks 
Javascript :: create mongodb express server npm 
Javascript :: js style 
Javascript :: Solution for Error [ERR_REQUIRE_ESM]: require() of ES Module 
Javascript :: join two arrays in js 
ADD CONTENT
Topic
Content
Source link
Name
7+5 =