Lekcja 4
This commit is contained in:
1 parent
72ed8ef789
commit
e42104c4fb
625 files changed
+66966
No files matched your search
@@ -0,0 +1,36 @@
|
||||
const express = require("express")
|
||||
const app = express()
|
||||
const PORT = 3000
|
||||
|
||||
const path = require('path')
|
||||
const formidable = require('formidable')
|
||||
|
||||
app.get("/", function (req, res) {
|
||||
res.sendFile(path.join(__dirname, '/static/form3.html'))
|
||||
})
|
||||
|
||||
app.post('/process_upload', function (req, res) {
|
||||
let formularz = formidable({})
|
||||
|
||||
formularz.uploadDir = __dirname + '/static/upload/'
|
||||
|
||||
formularz.parse(req, function (err, fields, files) {
|
||||
let danepliku = {
|
||||
"message": "file uploaded!",
|
||||
"wyslany_plik": {
|
||||
"size": files.wyslany_plik.size,
|
||||
"path": files.wyslany_plik.path,
|
||||
"name": files.wyslany_plik.name,
|
||||
"type": files.wyslany_plik.type
|
||||
}
|
||||
}
|
||||
|
||||
res.send(JSON.stringify(danepliku))
|
||||
})
|
||||
})
|
||||
|
||||
app.use(express.static('static'))
|
||||
|
||||
app.listen(PORT, function () {
|
||||
console.log("start serwera na porcie " + PORT)
|
||||
})
|
||||
Reference in new issue
Block a user