<input type="file" name="fileuploadAffifavit" id="fileuploadAffifavit" onchange="fileValidation_fileuploadAffifavit()" />
// Affidavit Of President
function fileValidation_fileuploadAffifavit() {
var fileInput =
document.getElementById('fileuploadAffifavit');
var filePath = fileInput.value;
// Allowing file type
var allowedExtensions =
/(\.jpg|\.jpeg|\.png|\.gif|\.pdf)$/i;
if (!allowedExtensions.exec(filePath)) {
alert('Invalid file type');
fileInput.value = '';
return false;
}
else {
const fi = document.getElementById('fileuploadAffifavit');
// Check if any file is selected.
if (fi.files.length > 0) {
for (const i = 0; i <= fi.files.length - 1; i++) {
const fsize = fi.files.item(i).size;
const file = Math.round((fsize / 1024));
// The size of the file.
if (file >= 3072) {
alert(
"File too Big, please select a file less than 3mb");
$('#fileuploadAffifavit').val('');
} else {
}
}
}
}
}
No comments :
Post a Comment