首页 > 其他分享 >dokuwiki支持Word粘帖

dokuwiki支持Word粘帖

时间:2023-02-23 11:22:34浏览次数:42  
标签:Word dokuwiki 粘帖 upload fileName content ext php 上传

如何做到 ueditor批量上传word图片?

1、前端引用代码

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

    <meta http-equiv="Content-Type"content="text/html; charset=utf-8"/>

 

   <title>编辑器完整版实例-1.2.6.0</title>

    <script type="text/javascript"src="ueditor.config.js"charset="utf-8"></script>

    <script type="text/javascript"src="ueditor.all.js"charset="utf-8"></script>

    <link type="text/css"rel="Stylesheet"href="WordPaster/css/WordPaster.css"/>

    <link type="text/css"rel="Stylesheet"href="WordPaster/js/skygqbox.css"/>

    <scrip ttype="text/javascript"src="WordPaster/js/json2.min.js"charset="utf-8"></script>

    <scrip ttype="text/javascript"src="WordPaster/js/jquery-1.4.min.js"charset="utf-8"></script>

    <scrip ttype="text/javascript"src="WordPaster/js/WordPaster.js"charset="utf-8"></script>

    <scrip ttype="text/javascript"src="WordPaster/js/skygqbox.js"charset="utf-8"></script>

</head>

<body>

    <textarea name="后台取值的key"id="myEditor">这里写你的初始化内容</textarea>

    <script type="text/javascript">

        var pasterMgr = new WordPasterManager();

    pasterMgr.Config["PostUrl"] = "http://localhost:81/WordPaster2/WordPasterUEditor1x/php/upload.php"

    pasterMgr.Load();//加载控件

 

          UE.getEditor('myEditor',{onready:function(){//创建一个编辑器实例

              pasterMgr.SetEditor(this);

          }});

    </script>

</body>

</html>

请求

文件上传的默认请求是一个文件,作为具有“upload”字段的表单数据。

响应:文件已成功上传

当文件成功上传时的JSON响应:

uploaded- 设置为1。

fileName - 上传文件的名称。

url - 上传文件的URL。

响应:文件无法上传

uploaded- 设置为0。

error.message - 要显示给用户的错误消息。

2、粘贴word里面的图片路径是fill://D 这种格式 我理解这种是非浏览器安全的 许多浏览器也不支持

目前项目是用了一种变通的方式:

先把word上传到后台 、poi解析、存储图片 、转换html、替换图片、放到富文本框里显示

(富文本显示有个坑:没找到直接给富文本赋值的方法 要先销毁 记录下

success : function(data) {

     $('#content').attr('value',data.imagePath);

     var editor = CKEDITOR.instances["content"]; //你的编辑器的"name"属性的值

     if (editor) {

       editor.destroy(true);//销毁编辑器

      }    

     CKEDITOR.replace('content'); //替换编辑器,editorID为ckeditor的"id"属性的值

     $("#content").val(result);    //对editor赋值

     //CKEDITOR.instances.contentCkeditor.setData($("#content").text());

 }

3.接收上传的图片并保存在服务端

<?php

ob_start();

//201201/10

$timeDir =date("Ym")."/".date("d");

$uploadDir =dirname(__FILE__).'/upload/'.$timeDir;

$curDomain = "http://".$_SERVER["HTTP_HOST"]."/";

//相对路径 http://www.ncmem.com/upload/2012-1-10/

$relatPath = $curDomain ."WordPaster2/WordPasterUEditor1x/php/upload/" . $timeDir . "/";

 

//自动创建目录。upload/2012-1-10

if(!is_dir($uploadDir))

{

mkdir($uploadDir,0777,true);

}

 

//如果PHP页面为UTF-8编码,请使用urldecode解码文件名称

//$fileName = urldecode($_FILES['postedFile']['name']);

//如果PHP页面为GB2312编码,则可直接读取文件名称

$fileName = $_FILES['file']['name'];

$tmpName = $_FILES['file']['tmp_name'];

 

//取文件扩展名jpg,gif,bmp,png

$path_parts =pathinfo($fileName);

$ext = $path_parts["extension"];

$ext =strtolower($ext);//jpg,png,gif,bmp

 

//只允许上传图片类型的文件

if($ext == "jpg"

    || $ext == "jpeg"

    || $ext == "png"

    || $ext == "gif"

    || $ext == "bmp")

{

    //年_月_日_时分秒毫秒.jpg

    $saveFileName = $fileName;

 

    //xxx/2011_05_05_091250000.jpg

    $savePath = $uploadDir . "/" . $saveFileName;

 

    //另存为新文件名称

    if (!move_uploaded_file($tmpName,$savePath))

    {

exit('upload error!' . "文件名称:" .$fileName . "保存路径:" . $savePath);

    }

}

 

//输出图片路径

//$_SERVER['HTTP_HOST']   localhost:81

//$_SERVER['REQUEST_URI'] /FCKEditor2.4.6.1/php/test.php

$reqPath =str_replace("upload.php","",$_SERVER['REQUEST_URI']);

echo $relatPath .  $saveFileName;

header('Content-type: text/html; charset=utf-8');

header('Content-Length: ' .ob_get_length());

?>

效果展示:

编辑

 

在使用前需要配置一下

详细思路及源码

示例下载:

wordpaster-vue3-cli-ueditor1.5wordpaster-vue-ueditor1.5wordpaster-asp.net-ueditor1.5xwordpaster-php-ueditor1xwordpaster-jsp-ueditor1x​

 

标签:Word,dokuwiki,粘帖,upload,fileName,content,ext,php,上传
From: https://www.cnblogs.com/zyzzz/p/17147264.html

相关文章

  • 转载:PageOffice在线只读打开word文件并禁止复制
    一、PageOffice禁止复制1、poCtrl.setAllowCopy(false);//禁止拷贝,权限比较大,系统的快捷键Ctrl+C,Ctrl+V也会受到影响,但是可以在其他程序中可以使用右键菜单进行拷贝粘贴......
  • 如何在Python中自动化处理word表格?
    最近遇到一个问题,就是一个文档里面有很多重复操作的一些数字需要整理为excel表格,主要是方便我们后期操作使用。首先是我对这些数据做了脱敏处理,但这些坐标也都是真是存在的......
  • 如何通过Java 代码设置 Word 文档页边距
    页边距是指页面的边线到文字的距离。通常可在页边距内部的可打印区域中插入文字和图形,也可以将某些项目放置在页边距区域中(如页眉、页脚和页码等)。在我们用的Word文档中,都......
  • 深度学习-Word2Vec
    目录前言基本原理CBOW和Skip-gram模型的区别优缺点应用场景使用方法学习word2Vec需要注意什么代码前言Word2Vec是一种用于将自然语言文本中的单词转换为向量表示的技......
  • 一键安装wordpress
    #!/bin/bash nginx_souecepwd=/usr/local/nginx#源码安装路径cdnginx_configpwd=/usr/local/nginx/confsystemd_ExecStartpwd=/usr/local/nginx/sbin/nginxif[!-......
  • hadoop - hadoop2.6 伪分布式 - eclipse 中 配置 和 示例 wordcount
    1.配置eclipse   1.1下载linux版的eclipse ​​百度云-大数据资料专辑​​  1.2解压   可以手动提取,也可以命令提取:yuan@LABELNET:~/JAVA$sudotar-zx......
  • dokuwiki支持pdf粘帖
    ​ ueditor粘贴不能粘贴word中的图片是一个很头疼的问题,在我们的业务场景中客户要求必须使用ueditor并且支持word的图片粘贴,因为这个需求头疼了半个月,因为前端方面因为安......
  • dokuwiki支持pdf导入
    ​ 当前功能基于PHP,其它语言流程大致相同 1.新增上传wordjson配置在ueditor\php\config.json中新增如下配置:     /* 上传word配置 */    "wordAction......
  • Spire Linux Word 转PDF 字体问题
    1、首先要考虑为什么会出现这个问题呢,在windows环境下是正常的,在linux环境下就有问题了2、问题原因:Spireword转pdf会依赖环境字段,如果文档中使用字体在linux环境上没有......
  • 如何通过C#/VB.NET代码在Word中更改字体颜色
    在日常工作中,我们有时会需要修改字体的颜色来突出文本重点,让读者更容易抓住文章要点。在今天这篇文章中,我将为大家介绍如何以编程方式,在Word更改字体颜色。本文将分为两部分......