Getting this parameter on load in node js

this is what i get as error

TypeError: Cannot read property 'file' of undefined
    at C:\node\project\server.js:17:25
    at Layer.handle [as handle_request] (C:\node\node_modules\express\lib\router\layer.js:95:5)
    at next (C:\node\node_modules\express\lib\router\route.js:137:13)
    at Route.dispatch (C:\node\node_modules\express\lib\router\route.js:112:3)
    at Layer.handle [as handle_request] (C:\node\node_modules\express\lib\router\layer.js:95:5)
    at C:\node\node_modules\express\lib\router\index.js:281:22
    at Function.process_params (C:\node\node_modules\express\lib\router\index.js:335:12)
    at next (C:\node\node_modules\express\lib\router\index.js:275:10)
    at Immediate.<anonymous> (C:\node\node_modules\multer\lib\make-middleware.js:53:37)
    at runCallback (timers.js:670:20)

      

my html code

  <form action = "http://127.0.0.1:8081/file_upload" method = "POST" 
     enctype = "multipart/form-data">
     <input type="file" name="file" size="50" />
       <br />
     <input type = "submit" value = "Upload File" />
  </form>

      

my js code

console.log(req.file.file.name);
console.log(req.file.file.path);
console.log(req.file.file.type);
var file = __dirname + "/" + req.file.file.name;

      

where am i doing wrong?

+3
node.js


source to share


No one has answered this question yet

Check out similar questions:

eleven
Node.js res.send is not a function
five
Mongoose / MongoDb error geoNear is not a function
1
TypeError: Unable to read property "mv" undefined in Node.js
1
Getting error while creating node in neo4j using js node
0
Unable to read "collect" properties of undefined MongoDB
0
TypeError: vision.labelDetection is not a function
0
passport.changePassword is not a function - passort-local-mongoose
0
Multer when receiving error "pass-encoding" undefined "
0
SequelizeJS error: TypeError: User.findAll is not a function
-2
Getting "TypeError: Unable to read property" collection of undefined "



All Articles
Loading...
X
Show
Funny
Dev
Pics