function base64(file) {
var reader = new FileReader();
var pos = file.target.files[0].name.lastIndexOf(".");
var type = file.target.files[0].name.substring(pos + 1);
if (type.toLowerCase() != "png" && type.toLowerCase() != 'jpg' && type.toLowerCase() != 'jpeg' && type.toLowerCase() != 'gif' && type.toLowerCase() != 'bmp') {
alert("格式错误,请上传'png、jpg、jpeg、bmp、gif'格式文件");
return;
}
num += 1;
reader.onloadend = (
function(e) {
imgurl = e.target.result;
}
);
// Read the file
reader.readAsDataURL(file.target.files[0]);
}