@@ -32,26 +32,26 @@ function checkImageValid (filepath) {
32
32
33
33
// upload image
34
34
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
+ } )
38
38
39
39
form . parse ( req , function ( err , fields , files ) {
40
- if ( err || ! files . image || ! files . image . path ) {
40
+ if ( err || ! files . image || ! files . image . filepath ) {
41
41
response . errorForbidden ( req , res )
42
42
} else {
43
43
if ( config . debug ) {
44
44
logger . info ( 'SERVER received uploadimage: ' + JSON . stringify ( files . image ) )
45
45
}
46
46
47
- if ( ! checkImageValid ( files . image . path ) ) {
47
+ if ( ! checkImageValid ( files . image . filepath ) ) {
48
48
return response . errorForbidden ( req , res )
49
49
}
50
50
51
51
const uploadProvider = require ( './' + config . imageUploadType )
52
- uploadProvider . uploadImage ( files . image . path , function ( err , url ) {
52
+ uploadProvider . uploadImage ( files . image . filepath , function ( err , url ) {
53
53
// remove temporary upload file, and ignore any error
54
- fs . unlink ( files . image . path , ( ) => { } )
54
+ fs . unlink ( files . image . filepath , ( ) => { } )
55
55
if ( err !== null ) {
56
56
logger . error ( err )
57
57
return res . status ( 500 ) . end ( 'upload image error' )
0 commit comments