Home > Web Front-end > HTML Tutorial > UEditor编辑器上传图片开发流程_html/css_WEB-ITnose

UEditor编辑器上传图片开发流程_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 11:32:50
Original
908 people have browsed it

在ueditor目录下找到uedior.config.js,找到如下三行:

1 ,imageUrl: "<%=path %>/controller.json" //图片上传提交后台对应的地址,路径固定为*/controller.*2 ,imagePath: "<%=path %>/ueditor/" //图片在服务器上的存储目录3 ,imageFieldName: "upload" //后台对应接收image的参数名
Copy after login

或者:

var ueditor = UE.getEditor('myEditor',{    imageUrl: "<%=path %>/servlet/UploadServlet", //图片上传提交后台对应的地址    imagePath: "<%=path %>/ueditor/",  //图片在服务器上的存储目录    imageFieldName: "upload"  //后台对应接收image的参数名});
Copy after login

注意:记得在uedior.config.js配置文件中把"serverUrl"注释掉

在/ueditor/_src/plugins/simpleupload.js文件中,把link = me.options.imageUrlPrefix + json.url; 改为link = getRootPath()+json.url;

最后配置服务器返回的数据格式,这需要这服务器端进行修改。对应于后台接收上传图片的那个controller,返回的格式需如下:

{'url':'60391393848223.jpg','title':'p1999637039.jpg','original':'p1999637039.jpg','state':'SUCCESS'}
Copy after login

注意:url用相对路径,这样就OK了。

//js获取项目根路径,如: http://localhost:8083/uimcardprjfunction getRootPath(){    //获取当前网址,如: http://localhost:8083/uimcardprj/share/meun.jsp    var curWwwPath=window.document.location.href;    //获取主机地址之后的目录,如: uimcardprj/share/meun.jsp    var pathName=window.document.location.pathname;    var pos=curWwwPath.indexOf(pathName);    //获取主机地址,如: http://localhost:8083    var localhostPaht=curWwwPath.substring(0,pos);    //获取带"/"的项目名,如:/uimcardprj    var projectName=pathName.substring(0,pathName.substr(1).indexOf('/')+1);    //return localhostPaht + projectName;    return localhostPaht+"/";}
Copy after login

 

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template