资源简介

在线版技术实现:CKEditor粘贴屏幕截图上传图片、使用HttpServlet接收文件实现,欢迎下载,调试。可以直接部署运行。复制上传、截屏上传等

资源截图

代码片段和文件信息

package ckeditor;


import java.io.*;  
import java.text.SimpleDateFormat;  
import java.util.*;  
import javax.servlet.ServletException;  
import javax.servlet.http.*;  
import org.apache.commons.fileupload.FileItem;  
import org.apache.commons.fileupload.FileItemFactory;  
import org.apache.commons.fileupload.disk.DiskFileItemFactory;  
import org.apache.commons.fileupload.servlet.ServletFileUpload;  
public class CKEditorUploadServlet extends HttpServlet {  
    private static String baseDir;// CKEditor的根目录  
    private static boolean debug = false;// 是否debug模式  
    private static boolean enabled = false;// 是否开启CKEditor上传  
    private static Hashtable allowedExtensions;// 允许的上传文件扩展名  
    private static Hashtable deniedExtensions;// 阻止的上传文件扩展名  
    private static SimpleDateFormat dirFormatter;// 目录命名格式:yyyyMM  
    private static SimpleDateFormat fileFormatter;// 文件命名格式:yyyyMMddHHmmssSSS  
    /** 
     * Servlet初始化方法 
     */  
    public void init() throws ServletException {  
        // 从web.xml中读取debug模式  
        debug = (new Boolean(getInitParameter(“debug“))).booleanValue();  
        if (debug)  
            System.out.println(“\r\n---- SimpleUploaderServlet initialization started ----“);  
        // 格式化目录和文件命名方式  
        dirFormatter = new SimpleDateFormat(“yyyyMM“);  
        fileFormatter = new SimpleDateFormat(“yyyyMMddHHmmssSSS“);  
        // 从web.xml中获取根目录名称  
        baseDir = getInitParameter(“baseDir“);  
        // 从web.xml中获取是否可以进行文件上传  
        enabled = (new Boolean(getInitParameter(“enabled“))).booleanValue();  
        if (baseDir == null)  
            baseDir = “/UserFiles/“;  
        String realbaseDir = getServletContext().getRealPath(baseDir);  
        File baseFile = new File(realbaseDir);  
        if (!baseFile.exists()) {  
            baseFile.mkdirs();  
        }  
        // 实例化允许的扩展名和阻止的扩展名  
        allowedExtensions = new Hashtable(3);  
        deniedExtensions = new Hashtable(3);  
        // 从web.xml中读取配置信息  
        allowedExtensions.put(“File“  
        stringToArrayList(getInitParameter(“AllowedExtensionsFile“)));  
        deniedExtensions.put(“File“  
        stringToArrayList(getInitParameter(“DeniedExtensionsFile“)));  
        allowedExtensions.put(“Image“  
    stringToArrayList(getInitParameter(“AllowedExtensionsImage“)));  
        deniedExtensions.put(“Image“           stringToArrayList(getInitParameter(“DeniedExtensionsImage“)));  
        allowedExtensions.put(“Flash“          stringToArrayList(getInitParameter(“AllowedExtensionsFlash“)));  
        deniedExtensions.put(“Flash“           stringToArrayList(getInitParameter(“DeniedExtensionsFlash“)));  
        if (debug)  
            System.out.println(“---- SimpleUploaderServlet initialization completed ----\r\n“);  
    }  
    public void doGet(HttpServletRequest request HttpServletResponse response)  
            throws ServletException IOException {  
      

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       1318  2018-12-06 11:56  dev\.classpath

     文件        282  2018-12-06 09:33  dev\.mymetadata

     文件       1221  2018-12-06 09:35  dev\.project

     文件        330  2018-12-06 11:51  dev\.settings\org.eclipse.jdt.core.prefs

     文件      10433  2018-12-06 13:45  dev\src\ckeditor\CKEditorUploadServlet.java

     文件       1555  2018-12-06 11:56  dev\src\Dao\ATextDao.java

     文件       1509  2018-12-06 11:31  dev\src\Dao\picDao.java

     文件       1932  2018-12-06 11:57  dev\src\Dao\picDao1.java

     文件       1512  2018-12-06 11:59  dev\src\Dao\picDao2.java

     文件       2576  2018-12-06 11:31  dev\src\product\domeImage.java

     文件       1668  2018-12-06 11:50  dev\src\regex\DealStrSub.java

     文件       3199  2018-12-06 09:35  dev\WebRoot\ckeditor\adapters\jquery.js

     文件       3025  2018-12-06 09:35  dev\WebRoot\ckeditor\build-config.js

     文件     211319  2018-12-06 09:35  dev\WebRoot\ckeditor\CHANGES.md

     文件     634253  2018-12-06 09:35  dev\WebRoot\ckeditor\ckeditor.js

     文件        982  2018-12-06 13:19  dev\WebRoot\ckeditor\config.js

     文件       3094  2018-12-06 09:35  dev\WebRoot\ckeditor\contents.css

     文件      12370  2018-12-06 09:35  dev\WebRoot\ckeditor\lang\af.js

     文件      15881  2018-12-06 09:35  dev\WebRoot\ckeditor\lang\ar.js

     文件      13367  2018-12-06 09:35  dev\WebRoot\ckeditor\lang\az.js

     文件      19001  2018-12-06 09:35  dev\WebRoot\ckeditor\lang\bg.js

     文件      16969  2018-12-06 09:35  dev\WebRoot\ckeditor\lang\bn.js

     文件      12487  2018-12-06 09:35  dev\WebRoot\ckeditor\lang\bs.js

     文件      13803  2018-12-06 09:35  dev\WebRoot\ckeditor\lang\ca.js

     文件      13692  2018-12-06 09:35  dev\WebRoot\ckeditor\lang\cs.js

     文件      12814  2018-12-06 09:35  dev\WebRoot\ckeditor\lang\cy.js

     文件      12989  2018-12-06 09:35  dev\WebRoot\ckeditor\lang\da.js

     文件      13582  2018-12-06 09:35  dev\WebRoot\ckeditor\lang\de-ch.js

     文件      13862  2018-12-06 09:35  dev\WebRoot\ckeditor\lang\de.js

     文件      19779  2018-12-06 09:35  dev\WebRoot\ckeditor\lang\el.js

............此处省略445个文件信息

评论

共有 条评论