<script type="text/plain" id="upload_ue"></script> <script type="text/javascript"> //重新实例化一个编辑器,防止在上面的editor编辑器中显示上传的图片或者文件 var _editor = UE.getEditor(‘upload_ue‘); _editor.ready(function () { //设置编辑器不可用 // _editor.setDisabled(); //隐藏编辑器,因为不会用到这个编辑器实例,所以要隐藏 _editor.hide(); //侦听图片上传 _editor.addListener(‘beforeInsertImage‘, function (t, arg) { //将地址赋值给相应的input,只去第一张图片的路径 $("#picture").attr("value", arg[0].src); //图片预览 $("#preview").attr("src", arg[0].src); }) }); //弹出图片上传的对话框 function upImage() { var myImage = _editor.getDialog("insertimage"); myImage.open(); } </script> <div class="controls"> <input type="hidden" id="picture" name="picture"> <img src="/img/blank.jpg" style="width:100px;height:100px;" id="preview" /><a href="javascript:void(0);" onclick="upImage();">上传图片</a> <span class="help-inline"></span> </div>
时间: 2024-09-22 00:58:20