How to find the size of the file in Node.js?

To get a file’s size in megabytes: var fs = require(“fs”); // Load the filesystem module var stats = fs.statSync(“myfile.txt”) var fileSizeInBytes = stats.size; // Convert the file size to megabytes (optional) var fileSizeInMegabytes = fileSizeInBytes / (1024*1024); or in bytes: function getFilesizeInBytes(filename) { var stats = fs.statSync(filename); var fileSizeInBytes = stats.size; return fileSizeInBytes; }

Node Multer unexpected field

The <NAME> you use in multer’s upload.single(<NAME>) function must be the same as the one you use in <input type=”file” name=”<NAME>” …>. So you need to change var type = upload.single(‘file’) to var type = upload.single(‘recfile’) in you app.js

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)