{"action":"created","issue":{"url":"https://api.github.com/repos/expressjs/multer/issues/189","labels_url":"https://api.github.com/repos/expressjs/multer/issues/189/labels{/name}","comments_url":"https://api.github.com/repos/expressjs/multer/issues/189/comments","events_url":"https://api.github.com/repos/expressjs/multer/issues/189/events","html_url":"https://github.com/expressjs/multer/issues/189","id":98481108,"number":189,"title":"Cannot make the simple example to work","user":{"login":"ningji","id":5289380,"avatar_url":"https://avatars.githubusercontent.com/u/5289380?v=3","gravatar_id":"","url":"https://api.github.com/users/ningji","html_url":"https://github.com/ningji","followers_url":"https://api.github.com/users/ningji/followers","following_url":"https://api.github.com/users/ningji/following{/other_user}","gists_url":"https://api.github.com/users/ningji/gists{/gist_id}","starred_url":"https://api.github.com/users/ningji/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ningji/subscriptions","organizations_url":"https://api.github.com/users/ningji/orgs","repos_url":"https://api.github.com/users/ningji/repos","events_url":"https://api.github.com/users/ningji/events{/privacy}","received_events_url":"https://api.github.com/users/ningji/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-07-31T22:17:55Z","updated_at":"2015-08-01T17:31:15Z","closed_at":"2015-08-01T17:31:15Z","body":"was following this\r\nhttps://codeforgeek.com/2014/11/file-uploads-using-node-js/#comment-29091\r\nThe only change is added \"single()\".\r\n\r\n```javascript\r\napp.use(multer({ dest: './uploads/',\r\n rename: function (fieldname, filename) {\r\n    return filename+Date.now();\r\n  },\r\nonFileUploadStart: function (file) {\r\n  console.log(file.originalname + ' is starting ...')\r\n},\r\nonFileUploadComplete: function (file) {\r\n  console.log(file.fieldname + ' uploaded to  ' + file.path)\r\n  done=true;\r\n}\r\n}).single('userPhoto'));\r\n```\r\n\r\nbut doesn't work, file does uploaded successfully, but never hit `onFileUploadStart`, `onFileUploadcomplete`.\r\n\r\nubuntu 12.04, node 0.12.7, express 4.13.1, multer 1.0.1.\r\n\r\nAny help appreciated. Thanks !\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/expressjs/multer/issues/comments/126938933","html_url":"https://github.com/expressjs/multer/issues/189#issuecomment-126938933","issue_url":"https://api.github.com/repos/expressjs/multer/issues/189","id":126938933,"user":{"login":"LinusU","id":189580,"avatar_url":"https://avatars.githubusercontent.com/u/189580?v=3","gravatar_id":"","url":"https://api.github.com/users/LinusU","html_url":"https://github.com/LinusU","followers_url":"https://api.github.com/users/LinusU/followers","following_url":"https://api.github.com/users/LinusU/following{/other_user}","gists_url":"https://api.github.com/users/LinusU/gists{/gist_id}","starred_url":"https://api.github.com/users/LinusU/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LinusU/subscriptions","organizations_url":"https://api.github.com/users/LinusU/orgs","repos_url":"https://api.github.com/users/LinusU/repos","events_url":"https://api.github.com/users/LinusU/events{/privacy}","received_events_url":"https://api.github.com/users/LinusU/received_events","type":"User","site_admin":false},"created_at":"2015-08-01T17:31:15Z","updated_at":"2015-08-01T17:31:15Z","body":"Also, having a global variable named `done` that all requests share and that never gets reset back to `false` will cause all kinds of hell. I would strongly urge you not to do it.\r\n\r\nRewriting the example for 1.0:\r\n\r\n```javascript\r\n/*Define dependencies.*/\r\nvar express = require('express')\r\nvar multer = require('multer')\r\n\r\n/*Configure the app */\r\nvar app = express()\r\nvar upload = multer({ dest: './uploads/' })\r\n\r\n/*Handling routes.*/\r\napp.get('/', function (req, res) {\r\n  res.sendfile('index.html')\r\n})\r\n\r\napp.post('/api/photo', upload.single('userPhoto'), function (req, res) {\r\n  console.log(req.files)\r\n  res.end('File uploaded.')\r\n})\r\n\r\n/*Run the server.*/\r\napp.listen(3000, function () {\r\n    console.log('Listening on port 3000')\r\n})\r\n```"}}