I have this code for crop image using jquery croppie plugin and upload using bootstrap modal. in my case i work with FileReader
$(document).ready(function(){
$image_crop = $('#image_demo').croppie({
enableExif: true,
viewport: {
width:200,
height:300,
type:'square' //circle
},
boundary:{
width:300,
height:300
}
});
var fileTypes = ['jpg', 'jpeg', 'png'];
$('#upload_image').on('change', function(){
var reader = new FileReader();
reader.onload = function (event) {
$image_crop.croppie('bind', {
url: event.target.result
}).then(function(){
console.log('jQuery bind complete');
});
}
reader.readAsDataURL(this.files[0]);
$('#uploadimageModal').modal('show');
});
$('.crop_image').click(function(event){
$image_crop.croppie('result', {
type: 'canvas',
size: 'viewport'
}).then(function(response){
$.ajax({
url:"../account/edit/profileimage",
type: "POST",
//dataType:"json",
data:{"image": response},
success:function(data)
{
/*
if(response.status === 'error'){
$('#uploadimageModal').animate({ scrollTop: $('#uploaderror').offset().top }, 500);
$('#uploaderror').html(response.message);
}
else {
*/
$('#uploadimageModal').modal('hide');
$('#uploaded_image').html(data);
/*
}
*/
}
});
})
});
});
Now in action i need to check filetype validation and show alert before load modal box. how do can i show alert message?!