0

Upload file using multer in express.js

As mentioned in the multer documentation: https://www.npmjs.com/package/multer We can specify the name of the uploaded file by setting "filename" in the multer.diskStorage() method. https://sololearn.com/compiler-playground/c1Ep8rxLlN6v/?ref=app But when I set filename, it throw this error: Error: ENOENT: no such file or directory, open 'F:\Project\shop\public\images\image_2025-04-28T20:03:46.975Z.jpg' and when I don't set "filename", the file is stored in the specified directory with a random name but without file extension. How can I fix it and store files correcly (with its exstension)?

28th Apr 2025, 9:36 PM
Hamidreza Abolfathi
Hamidreza Abolfathi - avatar
2 Respuestas
+ 2
Thanks, BroFar . This section of commented codes resolved my problem :) .replace(/:/g, '-')
29th Apr 2025, 9:35 AM
Hamidreza Abolfathi
Hamidreza Abolfathi - avatar