-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinfo.jsp
More file actions
141 lines (127 loc) · 5.08 KB
/
info.jsp
File metadata and controls
141 lines (127 loc) · 5.08 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="java.io.File" %>
<%@ include file="db.jsp"%>
<%
request.setCharacterEncoding("UTF-8");
// 기본 프로필 이미지 경로
String defaultImagePath = "https://maked.kr/common/img/default_profile.png";
String imagePath = defaultImagePath;
// 업로드된 프로필 사진이 있으면 경로 변경
File uploaded = new File(application.getRealPath("/upload/profile.jpg"));
if (uploaded.exists()) {
imagePath = "upload/profile.jpg";
}
// 세션 값 불러오기
String savedId = (String)session.getAttribute("id");
String savedNickname = (String)session.getAttribute("nickname");
String savedPassword = (String)session.getAttribute("password");
String savedMessage = (String)session.getAttribute("message");
String savedLv = (String)session.getAttribute("level");
String savedExp = (String)session.getAttribute("exp");
// 로그인 체크
if (savedId == null || savedId.trim().equals("")) {
response.sendRedirect("mainpage.jsp");
} else if (savedNickname == null || savedNickname.trim().equals("")) {
response.sendRedirect("mainpage.jsp");
} else if (savedPassword == null || savedPassword.trim().equals("")) {
response.sendRedirect("mainpage.jsp");
} else {
if (savedMessage == null) savedMessage = "";
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>프로필 설정</title>
<style>
body {
margin: 0; padding: 0; height: 100vh; width: 100vw;
display: flex; justify-content: center; align-items: center;
}
.Box { border: 3px solid; padding: 20px 50px 10px 50px; min-width: 420px; min-height: 220px; box-sizing: border-box; }
.profile-picture { text-align:center; margin-bottom:10px; }
.login_input { display: flex; flex-direction: column; gap: 10px; min-width: 130px; }
.login_input input { padding: 6px 6px; border: 2px solid; border-radius: 2px; outline: none; }
.button-row { display: flex; gap:180px; margin-top: 10px;align-items: center;}
.btn-save { margin-top: 10px; padding: 8px 18px; border: 2px solid; font-weight: bold; cursor: pointer; border-radius: 2px; }
.btn-delete { margin-top: 10px; padding: 8px 18px; border: 2px solid; font-weight: bold; cursor: pointer; border-radius: 2px; }
</style>
<script>
function previewImages(event) {
const files = event.target.files;
const preview = document.getElementById('preview');
preview.innerHTML = '';
if (files.length === 0) return;
const container = document.createElement('div');
container.style.display = 'grid';
container.style.gridTemplateColumns = 'repeat(3, 1fr)';
container.style.gap = '10px';
Array.from(files).forEach((file) => {
if (!file.type.startsWith('image/')) return;
const reader = new FileReader();
reader.onload = function(e) {
const img = document.createElement('img');
img.src = e.target.result;
img.style.width = '100%';
img.style.height = '100px';
img.style.objectFit = 'cover';
img.style.border = '1px solid #ccc';
img.style.borderRadius = '6px';
container.appendChild(img);
};
reader.readAsDataURL(file);
});
preview.appendChild(container);
}
function previewProfileImage(event) {
const file = event.target.files[0];
if (!file || !file.type.startsWith('image/')) return;
const reader = new FileReader();
reader.onload = function(e) {
document.getElementById('currentProfile').src = e.target.result;
};
reader.readAsDataURL(file);
}
function goBack() {
history.back();
}
</script>
</head>
<body>
<div class="Box">
<button type="button" class="btn-back" onclick="goBack()">←</button>
<h2>프로필 설정</h2>
<form action="profileSettings.jsp" method="post" enctype="multipart/form-data">
<div class="profile-picture">
<img id="currentProfile" src="<%= imagePath %>" alt="프로필 사진"
style="width:120px;height:120px;border-radius:60px;border:1px solid #aaa;">
<br /><br />
<input type="file" name="userProfile" accept="image/*" onchange="previewProfileImage(event)">
<div id="preview" style="margin-top:10px;"></div>
</div>
<div class="login_input">
<div>아이디</div>
<input type="text" name="id" value="<%= savedId %>" required readonly/>
<div>닉네임</div>
<input type="text" name="nickname" value="<%= savedNickname %>" required/>
<div>비밀번호</div>
<input type="text" name="password" value="<%= savedPassword %>" required/>
<div>상태 메시지</div>
<input type="text" name="message" value="<%= savedMessage %>" />
</div>
<div class="button-row">
<button type="submit" class="btn-save">저장</button>
<form action="profileSettings.jsp" method="post">
<button type="submit" class="btn-delete">회원탈퇴</button>
<form action="deleteform.jsp" method="post">
</form>
</div>
</form>
</form>
</div>
</div>
</body>
</html>
<%
}
%>