upload is not a function #215
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Hi,
I am getting error while upload files:
TypeError: upload is not a function at /home/.../myapp/index.js:55:3 at Layer.handle [as handle_request] (/home/../myapp/node_modules/express/lib/router/layer.js:95:5) at next (/home/.../myapp/node_modules/express/lib/router/route.js:131:13) at Route.dispatch (/home/.../myapp/node_modules/express/lib/router/route.js:112:3) at Layer.handle [as handle_request] (/home/.../myapp/node_modules/express/lib/router/layer.js:95:5) at /home/.../myapp/node_modules/express/lib/router/index.js:277:22 at Function.process_params (/home/.../myapp/node_modules/express/lib/router/index.js:330:12) at next (/home/.../myapp/node_modules/express/lib/router/index.js:271:10) at /home/.../myapp/index.js:16:3 at Layer.handle [as handle_request] (/home/.../myapp/node_modules/express/lib/router/layer.js:95:5)Can anyone help in that?
I have the same issue,does anyone handle it ?
Same issue being faced. However the file does get uploaded to the destination in spite of this error. The rename, onFileUploadStart, and onFileUploadComplete functions don't run and the file is saved with a random string as the name, without an extension.
Hello,
I know it's been a while since this issue was opened, but i stumbled on the same issue and found a solution thanks to @LinusU's comment on https://github.com/expressjs/multer/issues/203 :)
You need to add .single('fieldname') or .array(fieldname[, maxCount]) or .fields(fields) at the end when you declare your upload.
Example: const upload = multer({dest: DIR }).single('fieldname')
Hope it helps someone
EDIT:
You could even add .any() but it should just be used as a quick fix, not a permanent solution IMO
And in order to rename a file, multer.diskStorage should be used. Here is the documentation: https://github.com/expressjs/multer#diskstorage