Well, I'm trying to validate max_size in js, but as I do not understand much, I was able to only validate accepted formats (jpg, png, etc ...)
<input type="file" name="photo" id="photo" onchange="checkfile(this);" />
function checkfile(sender) {
var validExts = new Array(".zip", ".rar", ".pdf", ".jpeg", ".jpg", ".png", ".tif", ".gif", ".JPG");
var fileExt = sender.value;
fileExt = fileExt.substring(fileExt.lastIndexOf('.'));
if (validExts.indexOf(fileExt) < 0) {
alert("Invalid file selected, valid files are of " +
validExts.toString() + " types.");
return false;
}
else return true;
}
I have an example in hands, but I do not know how to put it together with checkthis
var uploadField = document.getElementById("file");
uploadField.onchange = function() {
if(this.files[0].size > 307200){
alert("File is too big!");
this.value = "";
};
};