Web/JSP_SERVLET

첨부파일 삭제 소스

벨포트조던 2016. 3. 11.
반응형

fileDel.jsp


<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

<%@ page import="java.io.*" %>

<%@ include file="../../include/accessRight.jsp"%>

<%

String requestUrl = request.getHeader("referer");

String strAttachNo = request.getParameter("attachno");

if(strAttachNo==null) strAttachNo = "0";

int attachNo = Integer.parseInt(strAttachNo);

String fileName = "";

String rs_attachRoute = "";

query = "select saveFileNm, attachRoute from g_attachedFile where attachNo = ? ";

pstmt = conn.prepareStatement(query);

pstmt.setString(1,strAttachNo);

rs = pstmt.executeQuery();

String realPath = saveFolder;

String rs_filename = "";

String filename = "";

if(rs.next()){

rs_filename = rs.getString("saveFileNm");

if(rs_filename==null) rs_filename = "";

   if(!rs_filename.equals("")){

   filename = rs_filename ;

   File f = new File(realPath + "/" + filename);

   if(f.exists()){

   

    f.delete();

   }

   }

}

rs.close();

pstmt.close();

query = "delete g_attachedFile where attachNo = ? ";

pstmt = conn.prepareStatement(query);

pstmt.setInt(1, attachNo);

pstmt.executeUpdate();

pstmt.close();

%>

<script type="text/javascript">

parent.$("#frm").attr({"action":"", "target":"_self"}).submit();

</script>

<%@include file="../../include/dbClose.jsp"%>

반응형

댓글