최예리

이미지 업로드 구현 성공

폴더 생성, 수정, 삭제 개선
node_modules
\ No newline at end of file
Copyright Joyent, Inc. and other Node contributors. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
# path
This is an exact copy of the NodeJS ’path’ module published to the NPM registry.
[Documentation](http://nodejs.org/docs/latest/api/path.html)
## Install
```sh
$ npm install --save path
```
## License
MIT
{
"_from": "path",
"_id": "path@0.12.7",
"_inBundle": false,
"_integrity": "sha1-1NwqUGxM4hl+tIHr/NWzbAFAsQ8=",
"_location": "/path",
"_phantomChildren": {},
"_requested": {
"type": "tag",
"registry": true,
"raw": "path",
"name": "path",
"escapedName": "path",
"rawSpec": "",
"saveSpec": null,
"fetchSpec": "latest"
},
"_requiredBy": [
"#USER",
"/"
],
"_resolved": "https://registry.npmjs.org/path/-/path-0.12.7.tgz",
"_shasum": "d4dc2a506c4ce2197eb481ebfcd5b36c0140b10f",
"_spec": "path",
"_where": "C:\\Users\\yeari\\Desktop\\경희대\\오픈소스SW개발\\Project\\OSS-Project",
"author": {
"name": "Joyent",
"url": "http://www.joyent.com"
},
"bugs": {
"url": "https://github.com/jinder/path/issues"
},
"bundleDependencies": false,
"dependencies": {
"process": "^0.11.1",
"util": "^0.10.3"
},
"deprecated": false,
"description": "Node.JS path module",
"homepage": "http://nodejs.org/docs/latest/api/path.html",
"keywords": [
"ender",
"path"
],
"license": "MIT",
"main": "./path.js",
"name": "path",
"repository": {
"type": "git",
"url": "git://github.com/jinder/path.git"
},
"version": "0.12.7"
}
This diff is collapsed. Click to expand it.
{
extends: "eslint:recommended",
"env": {
"node": true,
"browser": true,
"es6" : true,
"mocha": true
},
"rules": {
"indent": [2, 4],
"brace-style": [2, "1tbs"],
"quotes": [2, "single"],
"no-console": 0,
"no-shadow": 0,
"no-use-before-define": [2, "nofunc"],
"no-underscore-dangle": 0,
"no-constant-condition": 0,
"space-after-function-name": 0,
"consistent-return": 0
}
}
(The MIT License)
Copyright (c) 2013 Roman Shtylman <shtylman@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# process
```require('process');``` just like any other module.
Works in node.js and browsers via the browser.js shim provided with the module.
## browser implementation
The goal of this module is not to be a full-fledged alternative to the builtin process module. This module mostly exists to provide the nextTick functionality and little more. We keep this module lean because it will often be included by default by tools like browserify when it detects a module has used the `process` global.
It also exposes a "browser" member (i.e. `process.browser`) which is `true` in this implementation but `undefined` in node. This can be used in isomorphic code that adjusts it's behavior depending on which environment it's running in.
If you are looking to provide other process methods, I suggest you monkey patch them onto the process global in your app. A list of user created patches is below.
* [hrtime](https://github.com/kumavis/browser-process-hrtime)
* [stdout](https://github.com/kumavis/browser-stdout)
## package manager notes
If you are writing a bundler to package modules for client side use, make sure you use the ```browser``` field hint in package.json.
See https://gist.github.com/4339901 for details.
The [browserify](https://github.com/substack/node-browserify) module will properly handle this field when bundling your files.
// shim for using process in browser
var process = module.exports = {};
// cached from whatever global is present so that test runners that stub it
// don't break things. But we need to wrap it in a try catch in case it is
// wrapped in strict mode code which doesn't define any globals. It's inside a
// function because try/catches deoptimize in certain engines.
var cachedSetTimeout;
var cachedClearTimeout;
function defaultSetTimout() {
throw new Error('setTimeout has not been defined');
}
function defaultClearTimeout () {
throw new Error('clearTimeout has not been defined');
}
(function () {
try {
if (typeof setTimeout === 'function') {
cachedSetTimeout = setTimeout;
} else {
cachedSetTimeout = defaultSetTimout;
}
} catch (e) {
cachedSetTimeout = defaultSetTimout;
}
try {
if (typeof clearTimeout === 'function') {
cachedClearTimeout = clearTimeout;
} else {
cachedClearTimeout = defaultClearTimeout;
}
} catch (e) {
cachedClearTimeout = defaultClearTimeout;
}
} ())
function runTimeout(fun) {
if (cachedSetTimeout === setTimeout) {
//normal enviroments in sane situations
return setTimeout(fun, 0);
}
// if setTimeout wasn't available but was latter defined
if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
cachedSetTimeout = setTimeout;
return setTimeout(fun, 0);
}
try {
// when when somebody has screwed with setTimeout but no I.E. maddness
return cachedSetTimeout(fun, 0);
} catch(e){
try {
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
return cachedSetTimeout.call(null, fun, 0);
} catch(e){
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
return cachedSetTimeout.call(this, fun, 0);
}
}
}
function runClearTimeout(marker) {
if (cachedClearTimeout === clearTimeout) {
//normal enviroments in sane situations
return clearTimeout(marker);
}
// if clearTimeout wasn't available but was latter defined
if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
cachedClearTimeout = clearTimeout;
return clearTimeout(marker);
}
try {
// when when somebody has screwed with setTimeout but no I.E. maddness
return cachedClearTimeout(marker);
} catch (e){
try {
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
return cachedClearTimeout.call(null, marker);
} catch (e){
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
// Some versions of I.E. have different rules for clearTimeout vs setTimeout
return cachedClearTimeout.call(this, marker);
}
}
}
var queue = [];
var draining = false;
var currentQueue;
var queueIndex = -1;
function cleanUpNextTick() {
if (!draining || !currentQueue) {
return;
}
draining = false;
if (currentQueue.length) {
queue = currentQueue.concat(queue);
} else {
queueIndex = -1;
}
if (queue.length) {
drainQueue();
}
}
function drainQueue() {
if (draining) {
return;
}
var timeout = runTimeout(cleanUpNextTick);
draining = true;
var len = queue.length;
while(len) {
currentQueue = queue;
queue = [];
while (++queueIndex < len) {
if (currentQueue) {
currentQueue[queueIndex].run();
}
}
queueIndex = -1;
len = queue.length;
}
currentQueue = null;
draining = false;
runClearTimeout(timeout);
}
process.nextTick = function (fun) {
var args = new Array(arguments.length - 1);
if (arguments.length > 1) {
for (var i = 1; i < arguments.length; i++) {
args[i - 1] = arguments[i];
}
}
queue.push(new Item(fun, args));
if (queue.length === 1 && !draining) {
runTimeout(drainQueue);
}
};
// v8 likes predictible objects
function Item(fun, array) {
this.fun = fun;
this.array = array;
}
Item.prototype.run = function () {
this.fun.apply(null, this.array);
};
process.title = 'browser';
process.browser = true;
process.env = {};
process.argv = [];
process.version = ''; // empty string to avoid regexp issues
process.versions = {};
function noop() {}
process.on = noop;
process.addListener = noop;
process.once = noop;
process.off = noop;
process.removeListener = noop;
process.removeAllListeners = noop;
process.emit = noop;
process.prependListener = noop;
process.prependOnceListener = noop;
process.listeners = function (name) { return [] }
process.binding = function (name) {
throw new Error('process.binding is not supported');
};
process.cwd = function () { return '/' };
process.chdir = function (dir) {
throw new Error('process.chdir is not supported');
};
process.umask = function() { return 0; };
// for now just expose the builtin process global from node.js
module.exports = global.process;
{
"_from": "process@^0.11.1",
"_id": "process@0.11.10",
"_inBundle": false,
"_integrity": "sha1-czIwDoQBYb2j5podHZGn1LwW8YI=",
"_location": "/process",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "process@^0.11.1",
"name": "process",
"escapedName": "process",
"rawSpec": "^0.11.1",
"saveSpec": null,
"fetchSpec": "^0.11.1"
},
"_requiredBy": [
"/path"
],
"_resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz",
"_shasum": "7332300e840161bda3e69a1d1d91a7d4bc16f182",
"_spec": "process@^0.11.1",
"_where": "C:\\Users\\yeari\\Desktop\\경희대\\오픈소스SW개발\\Project\\OSS-Project\\node_modules\\path",
"author": {
"name": "Roman Shtylman",
"email": "shtylman@gmail.com"
},
"browser": "./browser.js",
"bugs": {
"url": "https://github.com/shtylman/node-process/issues"
},
"bundleDependencies": false,
"deprecated": false,
"description": "process information for node.js and browsers",
"devDependencies": {
"mocha": "2.2.1",
"zuul": "^3.10.3"
},
"engines": {
"node": ">= 0.6.0"
},
"homepage": "https://github.com/shtylman/node-process#readme",
"keywords": [
"process"
],
"license": "MIT",
"main": "./index.js",
"name": "process",
"repository": {
"type": "git",
"url": "git://github.com/shtylman/node-process.git"
},
"scripts": {
"browser": "zuul --no-coverage --ui mocha-bdd --local 8080 -- test.js",
"test": "mocha test.js"
},
"version": "0.11.10"
}
var assert = require('assert');
var ourProcess = require('./browser');
describe('test against our process', function () {
test(ourProcess);
});
if (!process.browser) {
describe('test against node', function () {
test(process);
});
vmtest();
}
function test (ourProcess) {
describe('test arguments', function () {
it ('works', function (done) {
var order = 0;
ourProcess.nextTick(function (num) {
assert.equal(num, order++, 'first one works');
ourProcess.nextTick(function (num) {
assert.equal(num, order++, 'recursive one is 4th');
}, 3);
}, 0);
ourProcess.nextTick(function (num) {
assert.equal(num, order++, 'second one starts');
ourProcess.nextTick(function (num) {
assert.equal(num, order++, 'this is third');
ourProcess.nextTick(function (num) {
assert.equal(num, order++, 'this is last');
done();
}, 5);
}, 4);
}, 1);
ourProcess.nextTick(function (num) {
assert.equal(num, order++, '3rd schedualed happens after the error');
}, 2);
});
});
if (!process.browser) {
describe('test errors', function (t) {
it ('works', function (done) {
var order = 0;
process.removeAllListeners('uncaughtException');
process.once('uncaughtException', function(err) {
assert.equal(2, order++, 'error is third');
ourProcess.nextTick(function () {
assert.equal(5, order++, 'schedualed in error is last');
done();
});
});
ourProcess.nextTick(function () {
assert.equal(0, order++, 'first one works');
ourProcess.nextTick(function () {
assert.equal(4, order++, 'recursive one is 4th');
});
});
ourProcess.nextTick(function () {
assert.equal(1, order++, 'second one starts');
throw(new Error('an error is thrown'));
});
ourProcess.nextTick(function () {
assert.equal(3, order++, '3rd schedualed happens after the error');
});
});
});
}
describe('rename globals', function (t) {
var oldTimeout = setTimeout;
var oldClear = clearTimeout;
it('clearTimeout', function (done){
var ok = true;
clearTimeout = function () {
ok = false;
}
var ran = false;
function cleanup() {
clearTimeout = oldClear;
var err;
try {
assert.ok(ok, 'fake clearTimeout ran');
assert.ok(ran, 'should have run');
} catch (e) {
err = e;
}
done(err);
}
setTimeout(cleanup, 1000);
ourProcess.nextTick(function () {
ran = true;
});
});
it('just setTimeout', function (done){
setTimeout = function () {
setTimeout = oldTimeout;
try {
assert.ok(false, 'fake setTimeout called')
} catch (e) {
done(e);
}
}
ourProcess.nextTick(function () {
setTimeout = oldTimeout;
done();
});
});
});
}
function vmtest() {
var vm = require('vm');
var fs = require('fs');
var process = fs.readFileSync('./browser.js', {encoding: 'utf8'});
describe('should work in vm in strict mode with no globals', function () {
it('should parse', function (done) {
var str = '"use strict";var module = {exports:{}};';
str += process;
str += 'this.works = process.browser;';
var script = new vm.Script(str);
var context = {
works: false
};
script.runInNewContext(context);
assert.ok(context.works);
done();
});
it('setTimeout throws error', function (done) {
var str = '"use strict";var module = {exports:{}};';
str += process;
str += 'try {process.nextTick(function () {})} catch (e){this.works = e;}';
var script = new vm.Script(str);
var context = {
works: false
};
script.runInNewContext(context);
assert.ok(context.works);
done();
});
it('should generally work', function (done) {
var str = '"use strict";var module = {exports:{}};';
str += process;
str += 'process.nextTick(function () {assert.ok(true);done();})';
var script = new vm.Script(str);
var context = {
clearTimeout: clearTimeout,
setTimeout: setTimeout,
done: done,
assert: assert
};
script.runInNewContext(context);
});
it('late defs setTimeout', function (done) {
var str = '"use strict";var module = {exports:{}};';
str += process;
str += 'var setTimeout = hiddenSetTimeout;process.nextTick(function () {assert.ok(true);done();})';
var script = new vm.Script(str);
var context = {
clearTimeout: clearTimeout,
hiddenSetTimeout: setTimeout,
done: done,
assert: assert
};
script.runInNewContext(context);
});
it('late defs clearTimeout', function (done) {
var str = '"use strict";var module = {exports:{}};';
str += process;
str += 'var clearTimeout = hiddenClearTimeout;process.nextTick(function () {assert.ok(true);done();})';
var script = new vm.Script(str);
var context = {
hiddenClearTimeout: clearTimeout,
setTimeout: setTimeout,
done: done,
assert: assert
};
script.runInNewContext(context);
});
it('late defs setTimeout and then redefine', function (done) {
var str = '"use strict";var module = {exports:{}};';
str += process;
str += 'var setTimeout = hiddenSetTimeout;process.nextTick(function () {setTimeout = function (){throw new Error("foo")};hiddenSetTimeout(function(){process.nextTick(function (){assert.ok(true);done();});});});';
var script = new vm.Script(str);
var context = {
clearTimeout: clearTimeout,
hiddenSetTimeout: setTimeout,
done: done,
assert: assert
};
script.runInNewContext(context);
});
});
}
Copyright Joyent, Inc. and other Node contributors. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
# util
[![Build Status](https://travis-ci.org/defunctzombie/node-util.png?branch=master)](https://travis-ci.org/defunctzombie/node-util)
node.js [util](http://nodejs.org/api/util.html) module as a module
## install via [npm](npmjs.org)
```shell
npm install util
```
## browser support
This module also works in modern browsers. If you need legacy browser support you will need to polyfill ES5 features.
{
"_from": "util@^0.10.3",
"_id": "util@0.10.4",
"_inBundle": false,
"_integrity": "sha512-0Pm9hTQ3se5ll1XihRic3FDIku70C+iHUdT/W926rSgHV5QgXsYbKZN8MSC3tJtSkhuROzvsQjAaFENRXr+19A==",
"_location": "/util",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "util@^0.10.3",
"name": "util",
"escapedName": "util",
"rawSpec": "^0.10.3",
"saveSpec": null,
"fetchSpec": "^0.10.3"
},
"_requiredBy": [
"/path"
],
"_resolved": "https://registry.npmjs.org/util/-/util-0.10.4.tgz",
"_shasum": "3aa0125bfe668a4672de58857d3ace27ecb76901",
"_spec": "util@^0.10.3",
"_where": "C:\\Users\\yeari\\Desktop\\경희대\\오픈소스SW개발\\Project\\OSS-Project\\node_modules\\path",
"author": {
"name": "Joyent",
"url": "http://www.joyent.com"
},
"browser": {
"./support/isBuffer.js": "./support/isBufferBrowser.js"
},
"bugs": {
"url": "https://github.com/defunctzombie/node-util/issues"
},
"bundleDependencies": false,
"dependencies": {
"inherits": "2.0.3"
},
"deprecated": false,
"description": "Node.JS util module",
"devDependencies": {
"zuul": "~1.0.9"
},
"files": [
"util.js",
"support"
],
"homepage": "https://github.com/defunctzombie/node-util",
"keywords": [
"util"
],
"license": "MIT",
"main": "./util.js",
"name": "util",
"repository": {
"type": "git",
"url": "git://github.com/defunctzombie/node-util.git"
},
"scripts": {
"test": "node test/node/*.js && zuul test/browser/*.js"
},
"version": "0.10.4"
}
module.exports = function isBuffer(arg) {
return arg instanceof Buffer;
}
module.exports = function isBuffer(arg) {
return arg && typeof arg === 'object'
&& typeof arg.copy === 'function'
&& typeof arg.fill === 'function'
&& typeof arg.readUInt8 === 'function';
}
\ No newline at end of file
This diff is collapsed. Click to expand it.
......@@ -585,6 +585,15 @@
"resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
"integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ=="
},
"path": {
"version": "0.12.7",
"resolved": "https://registry.npmjs.org/path/-/path-0.12.7.tgz",
"integrity": "sha1-1NwqUGxM4hl+tIHr/NWzbAFAsQ8=",
"requires": {
"process": "^0.11.1",
"util": "^0.10.3"
}
},
"path-parse": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz",
......@@ -595,6 +604,11 @@
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz",
"integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w="
},
"process": {
"version": "0.11.10",
"resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz",
"integrity": "sha1-czIwDoQBYb2j5podHZGn1LwW8YI="
},
"process-nextick-args": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz",
......@@ -911,14 +925,21 @@
"uglify-to-browserify": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz",
"integrity": "sha1-bgkk1r2mta/jSeOabWMoUKD4grc=",
"optional": true
"integrity": "sha1-bgkk1r2mta/jSeOabWMoUKD4grc="
},
"unpipe": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
"integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw="
},
"util": {
"version": "0.10.4",
"resolved": "https://registry.npmjs.org/util/-/util-0.10.4.tgz",
"integrity": "sha512-0Pm9hTQ3se5ll1XihRic3FDIku70C+iHUdT/W926rSgHV5QgXsYbKZN8MSC3tJtSkhuROzvsQjAaFENRXr+19A==",
"requires": {
"inherits": "2.0.3"
}
},
"util-deprecate": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
......
......@@ -2,8 +2,24 @@
const express = require('express');
const multer = require('multer');
var storage = multer.diskStorage({
destination: function (req, file, cb) {
var dir = req.params.directoryName;
cb(null, './tensorflow/data/' + dir + '/');
},
filename: function (req, file, cb) {
cb(null, new Date().valueOf() + "_" + file.originalname);
}
});
var upload = multer({
storage: storage
});
const bodyParser = require('body-parser');
const fs = require('fs');
const path = require('path');
const PORT = 8080;
const HOST = '0.0.0.0';
......@@ -23,12 +39,12 @@ app.use(bodyParser.urlencoded({extended:false}));
// Redirect Root to Home
app.get('/', (req, res) => {
res.redirect('/home');
res.redirect('./home/');
});
// Main Page
app.get('/home', (req, res) => {
app.get('/home/', (req, res) => {
fs.readdir(dataFolder, function(error, filelist){
if(error)
console.log(error);
......@@ -53,45 +69,50 @@ app.post('/directory_check', (req, res) => {
{
// Make directory
fs.mkdirSync(dataFolder + '/' + dir);
console.log('디렉토리: ' + dir + ' 생성 완료');
res.redirect('/home/' + dir);
console.log('Directory Create: ' + dir);
res.redirect('/home/' + dir + '/');
}
});
// Basic Directory Page
app.get('/home/:directoryName', (req, res) => {
app.get('/home/:directoryName/', (req, res) => {
// 아래 주석 처리된 코드는 화면에서 이미지를 보여주기 위한 코드
// 그러나 client에게 이미지를 보여주기 위해서는 Amazon S3를 이용해야 함
// 아직 Amazon S3 기능을 추가하지 못함
// var directoryName = new String(req.params.directoryName);
// var ImageList = new Array();
// var Path = dataFolder + '/' + directoryName;
// fs.readdirSync(Path).forEach(function(file,index){
// var fileType = path.extname(file);
// if(fileType == ".jpg" || fileType == ".jpeg") {
// ImageList.push("." + Path + "/" + file);
// }
// });
// res.render('directory', {FileList:ImageList});
var directoryName = req.params.directoryName;
res.render('directory', {directoryName:directoryName});
});
// Image Upload Directory Page
app.get('/home/:directoryName/upload', (req, res) => {
var upload_data = multer({ dest: 'tensorflow/data/' + directoryName });
upload_data.array('ImageData')
app.post('/home/:directoryName/upload/', upload.array('userImage'), (req, res) => {
var directoryName = req.params.directoryName;
var imgFileArr = req.files;
console.log("files: " + req.files);
res.redirect('/home/' + directoryName + '/');
});
// Modify Directory name
app.get('/home/:directoryName/modify', (req, res) => {
app.get('/home/:directoryName/modify/', (req, res) => {
// exist query.newName
var directoryName = new String(req.params.directoryName);
var newName = new String(req.query.newName);
var directoryName = req.params.directoryName;
var newName = req.query.newName;
if (req.query.newName) {
// modify Directory name and Files
var path = dataFolder + '/' + directoryName;
fs.readdirSync(path).forEach(function(file,index){
var curPath = path + "/" + file;
var fileNameArr = string.split("_");
var newPath = path + "/" + newName + "_" + fileNameArr[1];
fs.rename(curPath, newPath, function (err) {
if (err) {
console.log("File Rename error: " + err);
}
});
});
fs.rename(path, dataFolder + '/' + newName, function (err) {
// modify Directory name
var Path = dataFolder + '/' + directoryName;
fs.rename(Path, dataFolder + '/' + newName, function (err) {
if (err) {
console.log("Directory Rename error: " + err);
} else {
......@@ -107,9 +128,9 @@ app.get('/home/:directoryName/modify', (req, res) => {
// Delete Directory
app.get('/home/:directoryName/delete', (req, res) => {
app.get('/home/:directoryName/delete/', (req, res) => {
// exist query.real
var directoryName = new String(req.params.directoryName);
var directoryName = req.params.directoryName;
if (req.query.real) {
// Remove Directory and Files
var path = dataFolder + '/' + directoryName;
......@@ -118,6 +139,7 @@ app.get('/home/:directoryName/delete', (req, res) => {
fs.unlinkSync(curPath);
});
fs.rmdirSync(path);
console.log('Directory Delete: ' + dir);
res.redirect('/');
}
else {
......
......@@ -3,7 +3,27 @@ html
head
meta(charset='utf-8')
title 파일 업로드
style
img
| display="block"
| max-width="200px"
| max-height="200px"
| width="auto"
| height="auto"
body
form(action="upload" method="POST" enctype="multipart/form-data")
input(type="file", name="userfile[]", multiple="multiple")
input(type="submit", value="전송")
\ No newline at end of file
- var DirectoryName=directoryName;
h1=DirectoryName
h2 파일 업로드
br
br
form(action="./upload/" method="POST" enctype="multipart/form-data")
input(type="file", name="userImage", multiple="multiple", accept=".jpg, .jpeg")
input(type="submit", value="업로드")
br
//- var ImageList=FileList
each Image in ImageList
div(style="margin-right:10px; float:left;")
img(src=Image)
\ No newline at end of file
......
script.
var directoryName= !{directoryName};
confirm('모든 이미지가 삭제됩니다.\n정말 ' + directoryName + ' 분류를 삭제하시겠습니까?')
? location.href = location + 'real=true' : history.back();
\ No newline at end of file
? location.href ='.?real=true' : history.back();
\ No newline at end of file
......
......@@ -3,7 +3,7 @@ script.
var result = prompt('새 분류명을 입력하세요. (기존: ' + directoryName + ')');
if (result) {
location.href = location + 'newName=' + result;
location.href = '.?newName=' + result;
} else {
alert('분류명을 수정하지 않습니다.');
history.back();
......
<script type="text/javascript">
alert("이미 존재하는 분류입니다.");
history.back();
</script>
......@@ -7,14 +7,14 @@ html
body
form(action="directory_check" method="post")
form(action="../directory_check" method="post")
p 새로 만들 분류명:
input(name="directoryName", type="text")
input(type="submit", value="생성")
br
form(action="test" method="post" enctype="multipart/form-data")
form(action="../test" method="post" enctype="multipart/form-data")
p 테스트할 이미지:
input(name="ImageTest", type="file")
input(type="submit", value="테스트")
......@@ -26,13 +26,13 @@ html
each folder in folderList
div(style="margin-right:30px; float:left;")
li
a(href=location+folder)=folder
a(href="./"+folder+"/")=folder
div(style="margin-right:5px; float:left;")
form(action="home/"+folder+"/modify" method="get")
form(action="./"+folder+"/modify/" method="get")
input(type="submit", value="수정")
div
form(action="home/"+folder+"/delete" method="get")
form(action="./"+folder+"/delete/" method="get")
input(type="submit", value="삭제")
br
\ No newline at end of file
......