<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE html>
<html>

<head>
	<%@include file="/WEB-INF/views/include/head.jsp" %>
    <link rel="stylesheet" type="text/css" href="${ctxStatic }/js/fileinput/css/fileinput.min.css"/>
</head>
<%@ page isELIgnored="false"%>
<body>
<div class="pageContent" >
	<div class="row">
       <div class="col-sm-12">
           <div class="ibox float-e-margins">
               <div class="ibox-content">
                   <form class="form-horizontal m-t" class="pageForm required-validate">
                       <div class="form-group">
                           <label class="col-sm-3 control-label">照片：</label>
                           <div class="col-sm-8">
                               <input id="photo_file" class="file fileInput" type="file" data-preview-file-type="image" data-upload-url="${ctx }/manage/security/uploadHeadImg.do?sid=${ LOGIN_USER.sessionId}&idnum=${idnum}" data-preview-file-icon="">
                           </div>
                       </div>
                   </form>
               </div>
           </div>
       </div>
   </div>
</div>
<%@include file="/WEB-INF/views/include/foot.jsp" %>
<script type="text/javascript" src="${ctxStatic }/js/fileinput/js/fileinputNew.js?v=${version}"></script>
<script>
    var imgLoadIndex;
    //选择完事件
    $(".fileInput").on("filebatchselected", function(event, files) {
        $(this).fileinput("upload");// 执行上传动作
    });


    //上传中
    $('.fileInput').on('filepreupload', function(event, data, previewId, index) {     //上传中
        imgLoadIndex = parent.layer.load(0, {shade : [ 0.3, '#808080']});
    })
    // 上传完成事件
    $(".fileInput").on("fileuploaded",function(event, data, previewId, index) {
        parent.layer.close(imgLoadIndex);
        if (data.response.successful == true || data.response.successful == "true") {
            toastrSuccess("上传成功！");
            $("#imgArea").hide();
            $("#success").show();
            parent.refresh();
            setTimeout("parent.layer.closeAll();",2500);
        } else {
            if (data.response.msg != null && data.response.msg != "") {
                toastrError(data.response.msg);
            }
        }
    });

    //上传完成错误事件
    $(".fileInput").on('fileerror', function(event, data, msg) {  //一个文件上传失败
        parent.layer.close(imgLoadIndex);
        toastrError("上传异常，请重试!");


    })
</script>
</body>
</html>