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

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

CapamaniaCapamania Posts: 229Questions: 79Answers: 5
edited July 2019 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: 229Questions: 79Answers: 5

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

    fileName: Upload.Db.FileName,
    
  • allanallan Posts: 61,659Questions: 1Answers: 10,094 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

This discussion has been closed.