javascript check max file size upload code example
Example 1: how to get size of folder python
import os
def get_size(start_path = '.'):
total_size = 0
for dirpath, dirnames, filenames in os.walk(start_path):
for f in filenames:
fp = os.path.join(dirpath, f)
# skip if it is symbolic link
if not os.path.islink(fp):
total_size += os.path.getsize(fp)
return total_size
print(get_size(), 'bytes')
Example 2: get image file width javascript
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Get image width using File API</title>
</head>
<body>
<input type='file' onchange="readURL(this);" />
<script>
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
var img = new Image;
img.onload = function() {
console.log("The width of the image is " + img.width + "px.");
};
img.src = reader.result;
};
reader.readAsDataURL(input.files[0]);
}
}
</script>
</body>
</html>