upload is not a function #215

Open
opened 2016-05-23 10:43:59 +00:00 by consrv-suman · 3 comments
consrv-suman commented 2016-05-23 10:43:59 +00:00 (Migrated from github.com)

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?

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?
omarma commented 2017-04-05 11:20:33 +00:00 (Migrated from github.com)

I have the same issue,does anyone handle it ?

I have the same issue,does anyone handle it ?
suparnavg commented 2017-11-01 05:21:24 +00:00 (Migrated from github.com)

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.

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.
Blustch commented 2018-05-04 09:17:15 +00:00 (Migrated from github.com)

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

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
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: dc/ng2-file-upload#215