This plug-in is developed using JAVA technology and needs to be used with JavaScript. It can automatically upload local images (src is 'file:///') contained in the web page to the server and modify the src attribute of the img tag to the new image address. Typical application scenarios include: using it with ckEditor to automatically upload local images contained in content pasted from WORD to the server.
Dependent environment: JDK1.7+, jQuery, ckEditor4.2, no browser limit
General instructions for use
JavaScript API:
kind
WordImageUploader(s_url, app_name)
s_url: The server page address for image upload, which is a dynamic page, such as servlet, PHP, etc.;
app_name: The name of the current application
Before using this plug-in, you must first create an object of this class. It is best to have only one object of this class in a page. The creation method of this class is as follows
var uploader = new WordImageUploader(sUrl,appName);
The methods of this class are
uploadWordImagesFromCKEditor(editorInstance, pre_id)
This method is used to automatically upload all local pictures in the text pasted from WORD in CKEditor to the server. The meaning of the parameters is as follows
editorInstance: instance of CKEditor;
pre_id: The prefix of the name after the image is uploaded to the server to facilitate future cleaning and other maintenance work. If not needed, set it to '';
uploadLocalFile(localUrl, name)
This method is used to upload a single local image to the server. The meaning of the parameters is as follows:
localUrl: the local URL of the image, generally in the form: file:///xxx
name: the name of the picture
Usage steps
1. Introduce jQuery class library;
2. Introduce wordimage_uploader.js in the js folder;
3. Create WordImageUploader object;
4. Call the uploadWordImagesFromCKEditor method when the content of ckEditor changes.
After the plug-in is installed, "Monitoring Station: Welcome to use the "Local Image Automatic Upload Plug-in" should be displayed in the status file of the web page.
This plug-in supports all dynamic website technologies. The technology used in DEMO is jsp. The dynamic page that accepts uploaded files on the server side is Servelt: WordImageUploader.java. This file has been given in DEMO. For other dynamic website technologies, please refer to this file to implement it yourself.
For other usage details, please refer to the DEMO source code.