<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>JavaScript File Size</title>
<script>
// Get the file size using Javascript BEFORE going to the upload file
function showFileSize()
{
let file = document.getElementById("file").files[0]; // see file content at the end!!!
fs = (file ? file.size+" Bytes" : "Select a file");
document.getElementById("filesize").innerHTML = fs;
}
</script>
</head>
<body>
<div align="center">
<h1>Get local file size when selecting to upload</h1>
<input type="file" id="file" onchange="showFileSize()">
<span id="filesize"></span>
</div>
</body>
/*
file content:
lastModified: 1576146233403
lastModifiedDate: Thu Dec 12 2019 12:23:53 GMT+0200 (Israel Standard Time) {}
name: "weather_forecast.xlsx"
size: 41300636
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
webkitRelativePath: ""
*/
</html>