<label class="layui-form-label">图片</label>
<a class="layui-btn" id="image" style="float: left;"><i class="layui-icon"></i>上传图片</a>
<div class="layui-input-block" style="margin-left: 220px;">
<input type="text" name="img" value="{$tptc.img}" class="layui-input" style="position: absolute;left: 0;top: 0;">
</div>
</div>
<div class="layui-form-item">
<img style="margin-left: 110px;" id="img" src="{$tptc.img}">
</div>
<script>
layui.use('upload',function(){
var upload = layui.upload,
jq = layui.jquery;
upload.render({
url: '{:url("index/upload")}'
,elem:'#image'
,ext: 'jpg|png|gif'
,area: ['500', '500px']
,before: function(input){
loading = layer.load(2, {
shade: [0.2,'#000']
});
}
,done: function(res){
layer.close(loading);
jq('input[name=img]').val(res.path);
img.src = ""+res.path;
layer.msg(res.msg, {icon: 1, time: 1000});
}
});
})
</script>
|