$('input[type=file]').change(function() {
// validation for jpg|png|jpeg
uploadedFileName=this.value;
fieldName = this.name;
allowedFileFormat = [".jpg",".jpeg",".png"];
blnValid =false;
for (var j = 0; j < allowedFileFormat.length; j++) {
blnValid = true;
break;
}
if (!blnValid) {
$(this).val('');
alert("Uploaded file is not valid,allowed extension are jpg, jpeg, png");
return false;
}
}
property_image_size =this.files[0].size;
if(parseInt(property_image_size) > parseInt(20971520) ) { //20 MB
$(this).val('');
alert('Uploaded file size can not be more than 20MB');
return false;
}
});
// validation for jpg|png|jpeg
uploadedFileName=this.value;
fieldName = this.name;
allowedFileFormat = [".jpg",".jpeg",".png"];
blnValid =false;
for (var j = 0; j < allowedFileFormat.length; j++) {
var validFileExtention = allowedFileFormat[j];
uploadedFileExtention = uploadedFileName.substr(uploadedFileName.length - validFileExtention.length, validFileExtention.length).toLowerCase();
if (uploadedFileExtention == validFileExtention.toLowerCase()) {blnValid = true;
break;
}
if (!blnValid) {
$(this).val('');
alert("Uploaded file is not valid,allowed extension are jpg, jpeg, png");
return false;
}
}
property_image_size =this.files[0].size;
if(parseInt(property_image_size) > parseInt(20971520) ) { //20 MB
$(this).val('');
alert('Uploaded file size can not be more than 20MB');
return false;
}
});
Comments
Post a Comment