Baidu ueditor picture file changes default save to project root path, custom upload path or remote server: http://blog.csdn.net/slyn_2004/article/details/53868547
1. JS Instantiation Editor:
Instantiation Editor
var UE = ue.geteditor (' notice-content ');
Ue. Editor.prototype._bkgetactionurl = UE. EDITOR.PROTOTYPE.GETACTIONURL;
Ue. EDITOR.PROTOTYPE.GETACTIONURL = function (action) {
if (action = = ' Uploadimage ' | | action = = ' Uploadscrawl ' | | action = = ' ListImage ') {
return '/myproject/ueditorupload ';
} else {
return This._bkgetactionurl.call (this, action);
}
}
2. Backstage (with spring MVC):
@RequestMapping (value = "/ueditorupload") public void Uploadueditorimage (@RequestParam (value = "Upfile", require
D = False) Multipartfile file, httpservletresponse response, HttpServletRequest request) throws Exception {
Request.setcharacterencoding ("Utf-8");
Response.setcharacterencoding ("Utf-8");
Jsonobject json=new jsonobject ();
PrintWriter out = Response.getwriter ();
try {String root = "e:\\tmp";
String fileName = File.getoriginalfilename (); String Filesuffix = filename.substring (Filename.indexof (".")
+1);
SimpleDateFormat DateFormat = new SimpleDateFormat ("YyyyMMdd");
String directory = "\\file\\image\\" + Dateformat.format (new Date ()) + "\ \"; util.getrandomstring (int length): Returns a string consisting of the length of any letter that is of string path =directory + util.getrandomstring (12) +
"." + Filesuffix;
New File (root + directory). mkdir ();
File.transferto (new File (root + path)); JsoN.put ("state", "SUCCESS");
Json.put ("title", File.getname ());
Json.put ("url", path);//Picture Access Path Json.put ("original", File.getname ());
} catch (Exception e) {json.put ("state", "Error uploading picture");
} out.print (Json.tostring ()); }
3. In Config.json:
"Imageurlprefix": "http://localhost:8080",
"Imagepathformat": "/myproject/file/image/{yyyy}{mm}{dd}/{time}{ Rand:6} ",
4. Modify the Tomcat virtual path: http://blog.csdn.net/eunyeon/article/details/71124314
<context path= "" docbase= "E:\tmp" reloadable= "false" ></Context>