Reputation: 1753
I am using this package
to upload the image into server ,i want to check the file size before upload but express-fileupload
doesn't give any information about it
console.log(req.files.image)
; it returns only the name,data ,and image type
Upvotes: 0
Views: 2738
Reputation: 20536
Assuming the name of your file in your HTML file is image
, req.files.image.data.length
will give you the buffer length in bytes. See this Node.js. API Documentation for more details. You can then do the math to convert the number of bytes into any thing you want.
This will allow you to get the actual number of bytes independent of filetype and doesn't require using the mv
function. So you can use this on any file type not just images.
Hopefully this helps!
Upvotes: 4
Reputation: 751
I think only way to get image info using express-fileupload
is using mv
function to move image on server then using image-size
to get width and height
Upvotes: -1