Blame view

WebRoot/plugins/ueditor/jsp/fileUp.jsp 1.52 KB
ad5081d3   孙向锦   初始化项目
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
      <%@page import="java.io.File"%>
          <%@page import="java.util.Properties"%>
          <%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
          <%@ page import="ueditor.Uploader" %>
          <%@ page import="java.io.FileInputStream" %>
  
  
              <%
      request.setCharacterEncoding( Uploader.ENCODEING );
      response.setCharacterEncoding( Uploader.ENCODEING );
      
      String currentPath = request.getRequestURI().replace( request.getContextPath(), "" );
  
      File currentFile = new File( currentPath );
  
      currentPath = currentFile.getParent() + File.separator;
  
      //加载配置文件
      String propertiesPath = request.getSession().getServletContext().getRealPath( currentPath + "config.properties" );
      Properties properties = new Properties();
      try {
          properties.load( new FileInputStream( propertiesPath ) );
      } catch ( Exception e ) {
          //加载失败的处理
          e.printStackTrace();
      }
      
      Uploader up = new Uploader(request);
      
      up.setSavePath("upload"); //保存路径
      String[] fileType = {".rar" , ".doc" , ".docx" , ".zip" , ".pdf" , ".txt" , ".swf", ".wmv", ".avi", ".rm", ".rmvb", ".mpeg", ".mpg", ".ogg", ".mov", ".wmv", ".mp4"};  //允许的文件类型
      up.setAllowFiles(fileType);
      up.setMaxSize(500 * 1024);        //允许的文件最大尺寸,单位KB
      up.upload();
      response.getWriter().print("{'url':'"+up.getUrl()+"','fileType':'"+up.getType()+"','state':'"+up.getState()+"','original':'"+up.getOriginalName()+"'}");
  
  %>