node.jsheadlessexpress-fileupload

Node.JS Express express-fileupload file attributes without form (headless)


I am using the latest version of express-fileupload without a form. I intend to upload image file from Postman. How do I get the filename of the uploaded file?

let uploadedFile = req.files.file;
let filename = uploadedFile.name;
let mimeType = uploadedFile.mimetype;

I get the following error:

Property 'name' does not exist on type 'UploadedFile | UploadedFile[]'.
  Property 'name' does not exist on type 'UploadedFile[]'.ts(2339)

Solution

  • Ditch express-fileupload for multer. It works flawlessly!