ueditor富文本上传pdf并能实时预览

2018-09-10 16:00:24

1.ueditor的附件功能自带上传pdf功能。

        然而我使用的是github改装七牛版本的,缺提示  文件类型不允许


        这就尴尬了,通过文本搜素,也只能这样了,ueditor的js文件太大了,太复杂了。这个肯定是检测上传配置文件引起的。去看配置文件,发现页没啥问题。php error_log 打印配置项和路由,发现原来这个上传文件统一使用的uploadImg这个路由。

那就在上传图片的配置文件上放开了pdf上传。至此可以上传pdf了。


2.html进行pdf展示。(再放开插入html元素 iframe标签的前提下)

        虽然上传成功了,但是pdf是展现为附件的,这样就有点不好了。

        通过查看附件html代码,关键词搜索,然后去更改了插入pdf的地方。

        截取修改的代码。


for (i = 0; i < filelist.length; i++) {
    item = filelist[i];
    icon = iconDir + getFileIcon(item.url);
    title = item.title || item.url.substr(item.url.lastIndexOf('/') + 1);

    if(title.indexOf("pdf")>0){
        html +='<iframe style="width: 100%;height: 600px;border: 0px;overflow: hidden" width="100%" height="500px"  src="'+item.url+'"></iframe>'

    }else{
        html += '<p style="line-height: 16px;">' +
            '<img style="vertical-align: middle; margin-right: 2px;" src="'+ icon + '" _src="' + icon + '" />' +
            '<a style="font-size:12px; color:#0066cc;" href="' + item.url +'" title="' + title + '">' + title + '</a>' +
            '</p>';
    }


}
me.execCommand('insertHtml', html);

    完美实现。

  • 2019-05-25 14:54:50

    commit your changes or stash them before you can merge

    Your local changes to the following files would be overwritten by merge:         protected/config/main.php Please, commit your changes or stash them before you can merge. --------------------- 作者:陈小峰_iefreer 来源:CSDN 原文:https://blog.csdn.net/iefreer/article/details/7679631 版权声明:本文为博主原创文章,转载请附上博文链接!

  • 2019-05-27 10:43:34

    IntelliJ IDEA中C盘文件过大怎么办

    当我在D:\ 安装完IDEA9.0之后,建立了一个工程,发现C:\Users\Administrator\.IntelliJIdea90 竟然增大到了500+M,并且随着使用在逐渐增大,这样占用系统盘资源是非常让人不爽的,那么如何将其修改到其他路径呢?

  • 2019-05-28 13:33:20

    BRVAH+MTRVA,复杂?不存在的

    言归正传,这样的一个首页,我们需要做怎么样的基础工作呢?或者说,碰到以后更复杂的页面我们应该怎么做?这里小提示下,不要再用什么类似ScrollView的这种东西了,诶,好像说的有点绝对,尽量不要用,这不是谷歌想要看到的,5.0谷歌推出了RecyclerView,从它的整个设计架构来看,简直就是为这而生的。而RecyclerView的视图是通过Adapter来渲染的。原始的Adapter,让人很蛋疼,重复工作太多,我们应该要有封装的思想,把最需要的部分提供出来,其它不用管。

  • 2019-05-29 14:19:19

    解决Git中fatal: refusing to merge unrelated histories

    Git的报错 在使用Git的过程中有时会出现一些问题,那么在解决了每个问题的时候,都需要去总结记录下来,下次不再犯。 一、fatal: refusing to merge unrelated histories 今天在使用Git创建项目的时候,在两个分支合并的时候,出现了下面的这个错误。

  • 2019-05-29 15:47:51

    撤销commit

    在git push的时候,有时候我们会想办法撤销git commit的内容