<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ page import="com.quant.upload.AttachmentUploader" %>

<%
    request.setCharacterEncoding("utf-8");
	response.setCharacterEncoding("utf-8");
     AttachmentUploader up = new AttachmentUploader(request);
    //up.setSavePath("upload");
    String[] fileType = {".xls",".xlsx",".rar", ".doc",".docx", ".zip", ".pdf",".txt", ".swf", ".wmv", ".gif", ".png", ".jpg", ".jpeg", ".bmp","ppt","pptx"};
    up.setAllowFiles(fileType);
    up.setMaxSize(10000); //单位KB
    up.upload();
    
    String callback = request.getParameter("callback");
    
    String result = "{\"name\":\""+ up.getFileName()+"\", \"physicalPath\": \""+ up.getPhysicalPath() +"\", \"originalName\": \""+ up.getOriginalName() +"\", \"size\": "+ up.getSize() +", \"state\": \""+ up.getState() +"\", \"type\": \""+ up.getType() +"\", \"url\": \""+ up.getUrl() +"\"}";

    result = result.replaceAll( "\\\\", "\\/" );

    if( callback == null ){
        response.getWriter().print( result );
    }else{
        response.getWriter().print("<script>"+ callback +"(" + result + ")</script>");
    }
    %>
