<%@page language="java" contentType="application/x-msdownload" pageEncoding="iso8859-1"%><%@ page import="org.springframework.context.ApplicationContext"%><%@ page import="org.springframework.web.context.support.WebApplicationContextUtils"%><%@ page import="com.clove.cms.dao.AttachmentDAO"%><%@ page import="com.clove.cms.model.Attachment"%><%@ include file="config.jsp" %><% response.reset(); response.setContentType("application/force-download"); String pathfile = request.getParameter("pathfile"); if (pathfile == null || pathfile.trim().length() < 5) { return; } String filename = null; String fileType = ""; int len1 = pathfile.length(); int len2 = pathfile.lastIndexOf("/"); if (len1 > len2) { filename = pathfile.substring(len2 + 1); fileType = file.getFileType(filename); ApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(getServletConfig().getServletContext()); AttachmentDAO adao = (AttachmentDAO) ctx.getBean("AttachmentDAO"); Attachment attachment = adao.getByCondition(filename, null); if (attachment != null) { if (fileType.length() > 0) { filename = attachment.getName()+"."+fileType; } attachment = null; } ctx = null; } if (filename == null || filename.trim().length() < 5) { return; } String[] accessfile = new String[]{".html",".htm",".zip",".rar",".doc",".xls",".ppt",".txt",".pdf",".psd",".bmp",".jpg",".gif",".png",".swf",".avi",".wmv",".mp3",".ram",".rm",".flv",".mpeg"}; boolean bb = false; for (int i=0; i