Kindeditor单独调用多图上传实例
程序员文章站
2022-11-26 13:28:30
html代码:
html代码:
<input type="button" id="j_selectimage" value="图片上传" /> <div id="j_imageview"> <?php foreach($imgs as $row):?> <div class="img_view"><img class='iyuupload-view' src='/uploads/<?php echo $row['file_url'];?>'/><span class="view_del"id="<?=$row["id"]?>"><img deltarget="p_<?=$row['id']?>" src="/public/home/img/close_delete_2.png"></span></div> <input type='hidden' thumbid="p_<?=$row['id']?>" value='<?=$row['thumbnail_url']?>' name='thumbpath[]' > <input type='hidden' thumbid="p_<?=$row['id']?>" value='<?=$row['file_url']?>' name='imagepath[]'> <?php endforeach;?> </div>
js代码:
<script> function clearuploadpic(i,obj){ $("input[preimagepathid="+i+"]").val(""); $("input[prethumbpathid="+i+"]").val(""); obj.remove(); } kindeditor.ready(function(k) { window.editor = k.create('#editor_id', { height:'500px', uploadjson: '<?=u('upload/editorupload?uid='.cookie('uid'))?>', items : [ 'source','fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline', 'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist', 'insertunorderedlist', '|', 'image'] }); k('#j_selectimage').click(function() { editor.loadplugin('multiimage', function() { editor.plugin.multiimagedialog({ clickfn : function(urllist) { var div = k('#j_imageview'); //div.html(''); k.each(urllist, function(i, data) { div.append('<div class="img_view"><img src="' + data.url + '"><span class="view_del" onclick="clearuploadpic('+i+',$(this).parent())"><img src="/public/home/img/close_delete_2.png"></span></div>'); div.append('<input preimagepathid="'+i+'" name="imagepath[]" class="image-path" type="hidden" value="' + data.url +'">'); div.append('<input prethumbpathid="'+i+'" name="thumbpath[]" class="thumb-path" type="hidden" value="' + data.mini_url + '">'); //$("#thumbpath").val($("#thumbpath").val()+""+ data.mini_url); }); editor.hidedialog(); } }); }); }); }) </script>
以上这篇kindeditor单独调用多图上传实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。