Description:
I’m currently working on the backend of my project, utilizing Multer to handle image file uploads from the frontend. For the frontend, I’m using Postman as a testing tool.
Here’s a brief overview of the algorithm I’m developing for user registration:
- Users submit image files from the frontend.
- These files are temporarily stored in the project/temp folder, located in the root directory.
- Subsequently, the files are to be uploaded to Cloudinary.
You can find the full algorithm in the source code on my GitHub repository [https://github.com/mangesh123vispute/SocialMediaPro].
Problem:
While attempting to store files in the public/temp folder using Multer, I encounter the following error:
plaintext
Error: ENOENT: no such file or directory, open ‘C:UserslaxmaOneDriveDesktopcodinglearningbackendprojectpublictempmangesh.jpg’
Screenshots:
Issue Description:
I believe the problem lies within the multer.middleware.js
file rather than the user.controllers.js
. Here’s my reasoning:
- I added a
console.log("req.body: ", req.body);
statement inside theuser.controller.js
file. - However, this log statement is not being printed, indicating that the
registerUser
controller is not being called. - Therefore, I infer that the error is likely in the middleware (
multer.middleware.js
). - Additionally, the files (images) are not being stored in the
public/temp
folder as expected.
user.controllers.js:Added console.log() to check it is executing or not.
Question:
Can someone help me identify and resolve the issue in the multer.middleware.js
file that might be preventing the registerUser
controller from being called and causing the files not to be stored in the designated folder?