动易软件向网站服务器上传软件,动易CMS粘贴图片自动上传到服务器(Java版)

这种方法是servlet,编写好在web.xml里配置servlet-class和servlet-mapping即可使用

后台(服务端)java服务代码:(上传至ROOT/lqxcPics文件夹下)

page contentType="text/html;charset=utf-8"%>

page import = "Xproer.*" %>

page import="org.apache.commons.lang.StringUtils" %>

page import="org.apache.commons.fileupload.*" %>

page import="org.apache.commons.fileupload.disk.*" %>

page import="org.apache.commons.fileupload.servlet.*" %>

boolean isMultipart = ServletFileUpload.isMultipartContent(request);

FileItemFactory factory = new DiskFileItemFactory();

ServletFileUpload upload = new ServletFileUpload(factory);

List files = null;

try

{

files = upload.parseRequest(request);

}

catch (FileUploadException e)

{

out.println("上传文件异常:"+e.toString());

return;

}

FileItem imgFile = null;

Iterator fileItr = files.iterator();

while (fileItr.hasNext())

{

imgFile = (FileItem) fileItr.next();

if(imgFile.isFormField())

{

String fn = imgFile.getFieldName();

String fv = imgFile.getString();

if(fn.equals("uname")) uname = fv;

if(fn.equals("upass")) upass = fv;

}

else

{

break;

}

}

Uploader up = new Uploader(pageContext,request);

up.SaveFile(imgFile);

String url = up.GetFilePathRel();

out.write(url);

response.setHeader("Content-Length",url.length()+"");

%>

配置web.xml

xmlns="http://java.sun.com/xml/ns/javaee"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://java.sun.com/xml/ns/javaee

http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

index.jsp

前端(页面)测试代码:

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

WordPaster-jsp-ueditor-1.2.6.0

这里写你的初始化内容

var pasterMgr = new WordPasterManager();

//pasterMgr.Config["PostUrl"] = "http://www.ncmem.com/products/upload_ori.aspx"

pasterMgr.Config["PostUrl"] = "http://localhost:8080/WordPaster2UEditor1.4x/upload.jsp"

//pasterMgr.Config["PostUrl"] = "http://cloud.dyso.cn/ueditor/upload.jsp"

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

var ue = UE.getEditor('myEditor');

ue.ready(function() {

//设置编辑器的内容

ue.setContent('hello');

//获取html内容,返回:

hello

var html = ue.getContent();

//获取纯文本内容,返回: hello

var txt = ue.getContentTxt();

pasterMgr.SetEditor(ue);

});

实现后的效果,能够批量上传word中的全部图片,大幅度提升图片上传效率。而且能够保留Word样式。

3e5178fe21f8bc39416b3b125c4e951d.png

b374413897769aae5ac62af72bdd5746.png

图片上传完后,编辑器里面的图片地址也全部都改成了服务器的图片地址了,

a0420192ec7d2dbff71d58aa7c0cc046.png

b374413897769aae5ac62af72bdd5746.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值