@@ -104,8 +104,8 @@ Parse an incoming file upload, with the
104104[ Node.js's built-in ` http ` module] ( https://nodejs.org/api/http.html ) .
105105
106106``` js
107- const http = require ( ' http' ) ;
108- const formidable = require ( ' formidable' ) ;
107+ import http from ' http' ;
108+ import formidable from ' formidable' ;
109109
110110const server = http .createServer ((req , res ) => {
111111 if (req .url === ' /api/upload' && req .method .toLowerCase () === ' post' ) {
@@ -152,8 +152,8 @@ Or try the
152152[ examples/with-express.js] ( https://github.com/node-formidable/formidable/blob/master/examples/with-express.js )
153153
154154``` js
155- const express = require ( ' express' ) ;
156- const formidable = require ( ' formidable' ) ;
155+ import express from ' express' ;
156+ import formidable from ' formidable' ;
157157
158158const app = express ();
159159
@@ -198,8 +198,8 @@ which is Node.js's Request, and **NOT** the `ctx.request` which is Koa's Request
198198object - there is a difference._
199199
200200``` js
201- const Koa = require ( ' koa ' ) ;
202- const formidable = require ( ' formidable' ) ;
201+ import Koa from ' Koa ' ;
202+ import formidable from ' formidable' ;
203203
204204const app = new Koa ();
205205
@@ -298,20 +298,8 @@ _Please pass [`options`](#options) to the function/constructor, not by assigning
298298them to the instance ` form ` _
299299
300300``` js
301- const formidable = require ( ' formidable' ) ;
301+ import formidable from ' formidable' ;
302302const form = formidable (options);
303-
304- // or
305- const { formidable } = require (' formidable' );
306- const form = formidable (options);
307-
308- // or
309- const { IncomingForm } = require (' formidable' );
310- const form = new IncomingForm (options);
311-
312- // or
313- const { Formidable } = require (' formidable' );
314- const form = new Formidable (options);
315303```
316304
317305### Options
@@ -396,8 +384,6 @@ Parses an incoming Node.js `request` containing form data. If `callback` is
396384provided, all fields and files are collected and passed to the callback.
397385
398386``` js
399- const formidable = require (' formidable' );
400-
401387const form = formidable ({ multiples: true , uploadDir: __dirname });
402388
403389form .parse (req, (err , fields , files ) => {
@@ -521,8 +507,6 @@ Formidable instance (the `form` across the README examples) and the options.
521507** Note:** the plugin function's ` this ` context is also the same instance.
522508
523509``` js
524- const formidable = require (' formidable' );
525-
526510const form = formidable ({ keepExtensions: true });
527511
528512form .use ((self , options ) => {
@@ -547,11 +531,10 @@ which is used in [src/plugins/multipart.js](./src/plugins/multipart.js)), then
547531you can remove it from the ` options.enabledPlugins ` , like so
548532
549533``` js
550- const { Formidable } = require (' formidable' );
551-
552- const form = new Formidable ({
534+ import formidable , {octetstream , querystring , json } from " formidable" ;
535+ const form = formidable ({
553536 hashAlgorithm: ' sha1' ,
554- enabledPlugins: [' octetstream' , ' querystring' , ' json' ],
537+ enabledPlugins: [octetstream, querystring, json],
555538});
556539```
557540
0 commit comments