Skip to content

Commit f58c669

Browse files
authored
Merge pull request #1836 from hackmdio/bugfix/uploadimage-form
2 parents 070808b + 1b1ff89 commit f58c669

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

lib/imageRouter/index.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,26 +32,26 @@ function checkImageValid (filepath) {
3232

3333
// upload image
3434
imageRouter.post('/uploadimage', function (req, res) {
35-
var form = new formidable.IncomingForm()
36-
37-
form.keepExtensions = true
35+
var form = new formidable.IncomingForm({
36+
keepExtensions: true
37+
})
3838

3939
form.parse(req, function (err, fields, files) {
40-
if (err || !files.image || !files.image.path) {
40+
if (err || !files.image || !files.image.filepath) {
4141
response.errorForbidden(req, res)
4242
} else {
4343
if (config.debug) {
4444
logger.info('SERVER received uploadimage: ' + JSON.stringify(files.image))
4545
}
4646

47-
if (!checkImageValid(files.image.path)) {
47+
if (!checkImageValid(files.image.filepath)) {
4848
return response.errorForbidden(req, res)
4949
}
5050

5151
const uploadProvider = require('./' + config.imageUploadType)
52-
uploadProvider.uploadImage(files.image.path, function (err, url) {
52+
uploadProvider.uploadImage(files.image.filepath, function (err, url) {
5353
// remove temporary upload file, and ignore any error
54-
fs.unlink(files.image.path, () => {})
54+
fs.unlink(files.image.filepath, () => {})
5555
if (err !== null) {
5656
logger.error(err)
5757
return res.status(500).end('upload image error')

0 commit comments

Comments
 (0)