JS Baidu ueditor Picture upload configuration and the default use of remote URL address

Source: Internet
Author: User
Tags file upload

Picture upload configuration succeeded, the picture also uploaded, but there is a problem is the picture in the save time, using the relative address.

The red part is now the problem, I would like to change to the green section below with my site's absolute address.

Baidu search for a long time, encountered this problem is not much, but there is a friend did meet me this problem, reference:

http://blog.csdn.net/javaloverkehui/article/details/8465112

But his revised version belongs to an earlier version. I found no such configuration at all in the new edition. Or the location of the configuration is different.

No way, I return to Baidu Ueditor's official website, view the document. Found such a paragraph:

Document description
Support version: Support for Ueditor 1.4.2+ version

1.4.2+ configuration items that are primarily related to the path configuration later are Pathformat and URLPrefix configuration items.

These two configuration items are mainly for the following functions:

Picture upload: Imagepathformat, Imageurlprefix

Graffiti upload: Scrawlpathformat, Scrawlurlprefix

Screenshot upload: Snapscreenpathformat, Snapscreenurlprefix

Attachment upload: Filepathformat, Fileurlprefix

Video upload: Videopathformat, Videourlprefix

An example of the current document is a picture upload as an example, and other configuration methods are similar.

Imagepathformat Introduction
Function: Specify file upload path and return path, support format

1.4.2+ path configuration items are relative to the site root directory, regardless of whether they start with "/".
For example, suppose the site root is: "d://apache/www/", the following is the Imagepathformat configuration value and the corresponding storage directory.

The code is as follows Copy Code

"/upload/{filename}"--> "d://apache/www/upload/"

"Upload/{filename}"--> "d://apache/www/upload/"

"./upload/{filename}"--> "d://apache/www/upload/"

".. /upload/{filename} "-->" d://apache/upload/"

1 Specify File Save directory
The upload path can use a root path and a relative path, and it is recommended that you use a root path configuration.

1.1 Root Path starting with "/"
The Imagepathformat parameter recommends a configuration that starts with "/", which refers to the location relative to the site root.

Example: The site root directory is "d://apache/www/", the Imagepathformat parameter is set to "/upload/image/{filename}", then the upload location is "d://apache/www/upload/image/ "Directory.

1.2 Relative paths that start with non "/"
When the Imagepathformat parameter uses a relative path that begins with a non "/", the upload location is also relative to the site root (ASP,. NET exception, relative to the application's directory).

Example 1: The site root directory is "d://apache/www/" and the Imagepathformat parameter is set to "Ueditor/php/upload/{filename}", then the upload location is "d://apache/www/ueditor /php/upload/"directory.

Example 2: The site root is "d://apache/www/" and the Imagepathformat parameter is set to "... /upload/{filename} ", then the upload location is in the" d://apache/upload/"directory.

2 controlling the path inserted into the editor
2.1 Background return path
After the background execution upload is finished, the return path is the string that is replaced by the Imagepathformat configuration item and is output to the front end.

Example 1: The upload file name is 123.jpg,imagepathformat parameter set to "/ueditor/php/upload/{filename}", then the return path is "/ueditor/php/upload/123.jpg".

Example 2: The upload file name is 123.jpg,imagepathformat parameter set to ". /upload/{filename} ", then the return path is". /upload/123.jpg ".

2.2 Prefix the return path with the Imageurlprefix configuration item
There are cases where the return path alone does not get a normal picture link, and you need to prefix the path to insert the picture by configuring Imageurlprefix.

There are two scenarios in which you need to configure Imageurlprefix:

Under ASP and. NET, the application directory is not the site root, and you need to prefix the path.

In the case of Cross-domain uploads, you need to configure the Imageurlprefix prefix. Suppose the page is under the a.com domain, the file is uploaded to the B.Com domain, so to configure Imageurlprefix as "http://b.com" to get the normal path.

The red part of the bottom is the problem I encountered. Depending on the backend language, modifying the file path is different, but it's all modified: Config.json

The code is as follows Copy Code

/* Upload Picture configuration Item * *
"Imageactionname": "Uploadimage",/* Execute the action name of the uploaded image/*
"Imagefieldname": "Upfile", * * submitted picture form name * * *
"Imagemaxsize": 2048000,/* Upload size limit, Unit b * *
"Imageallowfiles": [". png", ". jpg", ". jpeg", ". gif", ". bmp"],/* Upload picture format display * *
' Imagecompressenable ': true,///compression of the picture, default is True/*
"Imagecompressborder": 1600,/* picture compression maximum edge limit * *
"Imageinsertalign": "None", * * Insert the picture floating mode * *
"Imageurlprefix": "http://192.168.3.9/ds/ueditor/net/",/* Image access Path prefix * *
"Imageurlprefix": "http://192.168.3.9/ds/ueditor/net/",//* Image access Path prefix * *

You can change it to an absolute address.

That will solve the problem.

Ueditor Other questions:

1, set the height: because Ueditor by default is to block all properties. The height is the default adaptive and can be opened by modifying the ueditor.config.js annotation option.

initialframeheight:500//Init editor height, default 320

or modify the default

2, Backstage Config.json is read by the Config.cs under the background class App_Code. I've had a loss in this place. If you find that the configuration has not changed after modifying the Config.json, you can do some monitoring on this function:

The code is as follows Copy Code

var json = File.readalltext (HttpContext.Current.Server.MapPath ("Config.json"));
Return Jobject.parse (JSON);

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.