<!-- title 标题
fvalue 值
field 字段名称
name  字段标识 -->
<div class="layui-form-item">
      <label class="layui-form-label"><?=$title?></label>
      <div class="layui-input-block">
        <input type="hidden" id="<?=$field?>_value"  name="<?=$name?>" value="<?=$fvalue?>">
          <div class="layui-upload">
            <button type="button" class="layui-btn" id="<?=$field?>">上传图片</button>
            <div class="layui-upload-list layui-upload-list_<?=$field?>" style="<?=$fvalue?"display: block":""?>">
              <div class="imgaa">
                  <img class="layui-upload-img" src="<?=$fvalue?>" id="<?=$field?>_item">
                <div class="delete_img"><i field="<?=$field?>" src="<?=$fvalue?>" class="layui-icon layui-icon-delete dandelete dandelete_<?=$field?>"></i></div>
              </div>
              
            </div>
         </div> 
      </div>
    </div>
    <script>
      
      layui.use(['upload'], function () {

       var  upload = layui.upload
       var $ = layui.jquery;
       var uploadInst = upload.render({
          elem: '#<?=$field?>' //绑定元素
          ,url: 'ajax.php?act=upload' //上传接口
        ,accept: 'file' //允许上传的文件类型
        ,exts:"jpg|png"
          ,done: function(res){
            //上传完毕回调
            res=res.data
            $("#<?=$field?>_value").val(res.src)
            $('#<?=$field?>_item').attr('src',res.src); 
            $(".layui-upload-list_<?=$field?>").show()
          }
          ,error: function(){
            //请求异常回调
          
          }
        });



      $(".dandelete_<?=$field?>").click(function(){
         var field=$(this).attr("field");
         $("#"+field+"_value").val("");
        // $("#"+field+"_item").attr("src","");
        $(".layui-upload-list_<?=$field?>").hide()
  })

      })
    </script> 

    <STYLE>
.layui-upload-img {
    width: 92px;
    height: 92px;
    margin: 0 10px 10px 0;
}
.layui-upload-list{display: none}
.delete_img {
    position: absolute;
    background-color: rgba(0,0,0,.5);
    width: 100%;
    bottom: 0;
    text-align: right;
    height: 25px;
    line-height: 25px;
    color: #fff;}
.imgaa{width: 92px; position: relative;}
</STYLE>