a node file upload example, here is

 (front-end code, doUpload) {var formData = new FormData ($("#uploadForm"); $.ajax ([0]) {url:'http://localhost:3011/upload', type:'POST', data: formData, async: false, cache: false, contentType: false, processData: false, success: function (returndata alert (returndata) {}); error: (returndata, function) {/ / Alert (returndata);}}}); < form id= "uploadForm" > < p> < input upload files: id= "UpImage" type= "file" name= "file" /> < input id=; "text" type= "text" name= "text" value= "232323" /> < /p> < input type= "button" value= onClick={this.doUpload.bind "Upload" (this)}/> < InP UT type= "button" onClick={(=>); {this.submit (value=)}} "OK" /> < /form> 

server code need to install the plug-in formidable

 exports.upload = function (req, res, next) {//keepExtensions true, display the file extension for VAR form = new formidable.IncomingForm ({keepExtensions:true}); / / the specified file directory form.uploadDir = path.join (__dirname); form.parse (req, function (err, fields, files) {//fields stored as JSON data is stored in //files file information / change the file directory, upload and display the name of fs.rename (files.file.path, __dirname+'/'+files.file.name, function (a, b) {} (res.json); {success:''}}); modified successfully)}; 

above is the entire contents, we hope to learn some help Help, also hope that a lot of people support the script home.

This paper fixed link:http://www.script-home.com/sample-code-for-node-js-file-upload-renaming-and-mobile-location.html | Script Home | +Copy Link

Article reprint please specify:Sample code for node.js file upload renaming and mobile location | Script Home

You may also be interested in these articles!