최예리

directory remove complete

...@@ -46,7 +46,7 @@ app.post('/directory_check', (req, res) => { ...@@ -46,7 +46,7 @@ app.post('/directory_check', (req, res) => {
46 if(fs.existsSync(dataFolder + '/' + dir)) 46 if(fs.existsSync(dataFolder + '/' + dir))
47 { 47 {
48 // Go back page 48 // Go back page
49 - res.sendfile('./views/error_directoryAdd.html'); 49 + res.render('error_directoryAdd');
50 } 50 }
51 // Directory doesn't exist 51 // Directory doesn't exist
52 else 52 else
...@@ -76,19 +76,19 @@ app.get('/home/:directoryName/upload', (req, res) => { ...@@ -76,19 +76,19 @@ app.get('/home/:directoryName/upload', (req, res) => {
76 // Delete Directory 76 // Delete Directory
77 app.get('/home/:directoryName/delete', (req, res) => { 77 app.get('/home/:directoryName/delete', (req, res) => {
78 // exist query.real 78 // exist query.real
79 - if (req.query.real != undefined) { 79 + var directoryName = req.params.directoryName;
80 + if (req.query.real) {
80 // Remove Directory and Files 81 // Remove Directory and Files
81 - path = dataFolder + '/' + directoryName; 82 + var path = dataFolder + '/' + directoryName;
82 fs.readdirSync(path).forEach(function(file,index){ 83 fs.readdirSync(path).forEach(function(file,index){
83 var curPath = path + "/" + file; 84 var curPath = path + "/" + file;
84 fs.unlinkSync(curPath); 85 fs.unlinkSync(curPath);
85 }); 86 });
86 fs.rmdirSync(path); 87 fs.rmdirSync(path);
87 - 88 + res.redirect('/');
88 - res.redirect('/home/');
89 } 89 }
90 else { 90 else {
91 - res.sendfile('./views/directoryDeleteCheck.html'); 91 + res.render('directoryDeleteCheck');
92 } 92 }
93 }); 93 });
94 94
......
1 -<script type="text/javascript">
2 -var delete = confirm("모든 이미지가 삭제됩니다.\n정말 분류를 삭제하시겠습니까?")
3 -if(delete)
4 - window.location.href = window.location + '?real=true'
5 -else
6 - history.back()
7 -</script>
...\ No newline at end of file ...\ No newline at end of file
1 +script.
2 + confirm("모든 이미지가 삭제됩니다. 정말 분류를 삭제하시겠습니까?") ? location.href = location + 'real=true' : history.back();
1 +script.
2 + alert("이미 존재하는 분류입니다.");
3 + history.back();
...\ No newline at end of file ...\ No newline at end of file
...@@ -8,12 +8,12 @@ html ...@@ -8,12 +8,12 @@ html
8 p 새로 만들 분류명: 8 p 새로 만들 분류명:
9 input(name="directoryName", type="text") 9 input(name="directoryName", type="text")
10 input(type="submit", value="생성") 10 input(type="submit", value="생성")
11 - p 11 + br
12 form(action="test" method="post" enctype="multipart/form-data") 12 form(action="test" method="post" enctype="multipart/form-data")
13 p 테스트할 이미지: 13 p 테스트할 이미지:
14 input(name="ImageTest", type="file") 14 input(name="ImageTest", type="file")
15 input(type="submit", value="테스트") 15 input(type="submit", value="테스트")
16 - 16 + br
17 ul 17 ul
18 - var folderList=fileList 18 - var folderList=fileList
19 each folder in folderList 19 each folder in folderList
......