Baidu Rich Text editor Ueditor 1.4.3 custom Picture Save path

Source: Internet
Author: User
Tags dateformat json

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>  


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.