Skip to content

Instantly share code, notes, and snippets.

@nanha
Last active December 12, 2015 04:19
Show Gist options
  • Save nanha/4713889 to your computer and use it in GitHub Desktop.
Save nanha/4713889 to your computer and use it in GitHub Desktop.
@da Young Shin 님에게 제공
expressjs 설치 후, 아래 3개 파일만 변경하면 업로드가 가능합니다.
views/index.jade
==================
extends layout
block content
h1= title
p Welcome to #{title}
form(method="post",enctype="multipart/form-data",action="/upload")
input(type="file", name="file")
input(type="submit")
app.js
======
app.post('/upload', routes.upload);
routes/index.js
================
exports.upload = function(req, res){
console.log(req.files);
res.send(req.files);
};
결과
{
"file": {
"size": 96581,
"path": "/tmp/a665eca8540846b5dbeaf6eb37fd0d79",
"name": "pic4.jpg",
"type": "image/jpeg",
"hash": false,
"lastModifiedDate": "2013-02-05T11:31:32.392Z",
"_writeStream": {
"path": "/tmp/a665eca8540846b5dbeaf6eb37fd0d79",
"fd": 10,
"writable": false,
"flags": "w",
"encoding": "binary",
"mode": 438,
"bytesWritten": 96581,
"busy": false,
"_queue": [],
"drainable": true
},
"length": 96581,
"filename": "pic4.jpg",
"mime": "image/jpeg"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment