修复更改个人头像上传文件类型限定为图片。

pull/9/head
yangzhengze 7 years ago
parent 4bc46c5fbf
commit 5096b2267c

@ -13,7 +13,7 @@
<div class="action"> <div class="action">
<div class="new-contentarea tc"> <div class="new-contentarea tc">
<a href="javascript:void(0)" class="upload-img"> <label for="avatar">上传图像</label> </a> <a href="javascript:void(0)" class="upload-img"> <label for="avatar">上传图像</label> </a>
<input type="file" class="" name="avatar" id="avatar" /> <input type="file" class="" name="avatar" id="avatar" accept="image/*"/>
</div> </div>
<input type="button" id="btnCrop" class="Btnsty_peyton" value="裁切" /> <input type="button" id="btnCrop" class="Btnsty_peyton" value="裁切" />
<input type="button" id="btnZoomIn" class="Btnsty_peyton" value="+" /> <input type="button" id="btnZoomIn" class="Btnsty_peyton" value="+" />
@ -37,8 +37,13 @@ $(window).load(function() {
var reader = new FileReader(); var reader = new FileReader();
reader.onload = function(e) { reader.onload = function(e) {
options.imgSrc = e.target.result; options.imgSrc = e.target.result;
//根据MIME判断上传的文件是不是图片类型
if((options.imgSrc).indexOf("image/")==-1){
alert("错误提示\n" + " 请上传图片类型!");
} else {
cropper = $('.imageBox').cropbox(options); cropper = $('.imageBox').cropbox(options);
} }
}
reader.readAsDataURL(this.files[0]); reader.readAsDataURL(this.files[0]);
}) })
$('#blobSubmit').on('click', function(){ $('#blobSubmit').on('click', function(){

Loading…
Cancel
Save