Editor node.js - File upload example error - 'FileName' of undefined

Editor node.js - File upload example error - 'FileName' of undefined

CapamaniaCapamania Posts: 209Questions: 71Answers: 5
edited July 17 in Editor

Editor node.js - File upload example error - 'FileName' of undefined. I'm testing the file upload function but getting an error:

TypeError: Cannot read property 'FileName' of undefined

I tried the example from here:

https://editor.datatables.net/manual/nodejs/upload

That's my setup:

let {
    Editor,
    Field,
    Validate,
    Format,
    Upload,
    Options
} = require('datatables.net-editor-server');

let editor = new Editor( db, 'news', 'id' )
.fields(
  new Field( 'news.id', 'id' ),
  new Field( 'news.cruser_id', 'cruser_id' ),
  new Field( 'news.image', 'image' )
    .setFormatter( Format.ifEmpty(null) )
    .upload( new Upload( __dirname + '/public/uploads/{id}.{extn}' )
        .db('image', 'id', {
            fileName: Upload.DbType.FileName,
            //fileSize: Upload.DbType.FileSize,
            //web_path: '/uploads/{id}.{extn}',
            //system_path: Upload.Db.SystemPath
        })
    
   )
)

Why is FileName undefined and how to get it work?

This question has an accepted answers - jump to answer

Answers

  • CapamaniaCapamania Posts: 209Questions: 71Answers: 5

    The docs should be updated ... it must be:

    fileName: Upload.Db.FileName,
    
  • allanallan Posts: 50,047Questions: 1Answers: 7,403 Site admin
    Answer ✓

    Thank you - that's really an error in the code. I'll add an alias so Db or DbType will work.

    Allan

Sign In or Register to comment.