【发布时间】:2016-10-08 19:07:34
【问题描述】:
这是我的 HTML 页面,我想在其中发送图像文件以及有关 TODO 任务和描述的信息。 http://pastebin.com/W9TVy4An
form.on('part', (part) => {
if (part.filename) {
let imagePath = ''
let privateIndex // will hold the index for private images
let index // will hold the index for the public images
let file = ''
part.setEncoding('binary')
part.on('data', (data) => {
file += data
})
part.on('end', () => {
if (isPrivate) {
// handle a private image
} else {
// handle a public image
}
if (!fs.existsSync(imagePath)) {
fs.mkdir(imagePath) // create the folder for the image
}
imagePath += isPrivate ? privateIndex + '.jpg' : index + '.jpg' // add the image name to complete the path for saving
fs.writeFile(imagePath, file, 'ascii', (err) => {
// stuff
}
})
callback(part.filename)
})
我知道如何使用 node.js 中的多方接收文件,如上所示,但我无法终生接收有关 TODO 任务的描述和名称的信息。
谁能告诉我怎么做或指出我犯的一些愚蠢的错误?
【问题讨论】:
标签: html node.js web webserver