<script src=
"__PUBLIC__/js/mbUploadify.js"
></script>
<script>
var
upload1 =
new
mbUploadify({
file: document.getElementById('imgfile'),
url:
"{:U('Upload/mbUploadImg')}"
,
progress:
function
(){
$('#imgpath').show();
$('#imgpath').val('上传中...');
},
error:
function
(file, msg){
document.getElementById('imgError').innerHTML = msg;
},
uploadSuccess:
function
(res){
$('#imgpath').hide();
$('#imgpath').val('');
var
data = JSON.parse(res);
document.getElementById('img-data').innerHTML = '<span
class
=
"uploadimg"
>' +
'<img src=
"'+ data.savepath +'"
style=
"max-width: 300px;"
>' +
'<input type=
"hidden"
name=
"img"
value=
"'+data.id+'"
>'+
'<a
class
=
"remove-uploadimg"
title=
"删除"
>✕</a>' +
'</span>';
}
});
$('body').on('click','.remove-uploadimg',
function
(){
$(this).parents('.uploadimg').remove();
})</script>