javascript - How to get the name of this file using formidable (NodeJs) -


i have form using nodejs + express

jade file:

form(method="post", action="/upload", enctype="multipart/form-data")   input(type="file" name="image")   button(type="submit") upload 

index.js not code necessary

var formidable = require('formidable'), http = require('http'), util = require('util'); var fs = require('fs');   myproject.post('/upload',function(req, res){ var form = new formidable.incomingform(); form.parse(req, function(err, fields, files)  {   console.log(files); }); 

when use console.log(files) result this

{ iproducto:   { domain: null,  _events: {},  _maxlisteners: 10,  size: 1262294,  path: 'c:\\docume~1\\admini~1\\config~1\\temp\\556696bb1c0c6a54362b746c4445   45ca',  name: 'dibujo.bmp',  type: 'image/bmp',  hash: null,    lastmodifieddate: mon jun 09 2014 21:25:42 gmt-0100 (hora estándar de cabo  verde),  _writestream:   { _writablestate: [object],     writable: true,     domain: null,     _events: {},     _maxlisteners: 10,     path: 'c:\\docume~1\\admini~1\\config~1\\temp\\556696bb1c0c6a54362b746c4     44545ca',     fd: null,     flags: 'w',     mode: 438,     start: undefined,     pos: undefined,     byteswritten: 1262294,     closed: true } } } 

now ok need file name , if use console.log(files.name) result undefined how can name value

you can access filename field name: files.iproducto.name.


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -