放在表单中,未上传图片,加一下data:判断,数组:[有图],没图为空!
Cupload 控件不错!
js:
//未上传图片
var img = "{$edit.img}";
var imgFile = '';
if (img) {
imgFile = [img];
}
//Cupload上传图片
var upload_img = new Cupload({
ele: '#upload_img',
name: "image",
url: "{:url('admin/upload')}",
data: imgFile
});
回复
接上次疑问,附上代码
Image: function(n) {
event.preventDefault();
event.stopPropagation();
uploadFile.splice(n, 1);
this.imageBox[n].remove();
this.removeUploadBox();
if (this.imageList.children.length < this.opt.num) {
this.createUploadBox()
}
},
removeUploadBox: function() {
this.uploadBox.remove()
},
showImage: function(m) {
event.preventDefault();
event.stopPropagation();
console.log(event.target.tagName);
let elem = this.image[m];
this.image[m].style.opacity = 1;
this.image[m].style.display = 'block';
$(elem).find('.cupload--btn').css('display', 'block');
},
hideImage: function(m) {
this.image[m].style.opacity = 0;
this.image[m].style.display = 'none';
let elem = this.image[m];
$(elem).find('.cupload--btn').css('display', 'none')
},
回复