Upload Many Get Error Display On 2nd File
Upload Many Get Error Display On 2nd File
Link to test case:
Debugger code (debug.datatables.net):
https://debug.datatables.net/oyoxuz
Error messages shown:
Cannot read property 'web_path' of undefined
Description of problem:
Hello,
i got an error when i use uploadMany with display image, the problem on first upload that's fine, but on second upload it got this Cannot read property 'web_path' of undefined error, so the image wont display on editor popup, but when i submit this editor doing good, all data sended,
Here my code
public function loadkelas($post)
{
Editor::inst( $this->editorDb, 'class', 'id' )
->fields(
Field::inst( 'id' ),
Field::inst( 'nama' ),
Field::inst( 'fasilitas' )
)
->join(
Mjoin::inst( 'files' )
->link( 'class.id', 'room_files.class_id' )
->link( 'files.id', 'room_files.file_id' )
->fields(
Field::inst( 'id' )
->upload( Upload::inst( $_SERVER['DOCUMENT_ROOT'].'/uploads/file/__ID__.__EXTN__' )
->db( 'files', 'id', array(
'filename' => Upload::DB_FILE_NAME,
'filesize' => Upload::DB_FILE_SIZE,
'web_path' => Upload::DB_WEB_PATH,
'system_path' => Upload::DB_SYSTEM_PATH
) )
->validator( Validate::fileSize( 500000, 'Files must be smaller that 500K' ) )
->validator( Validate::fileExtensions( array( 'png', 'jpg', 'jpeg', 'gif' ), "Please upload an image" ) )
)
)
)
->process( $_POST )
->json();
}
Javascript
editor2 = new $.fn.dataTable.Editor( {
ajax: "Ajax/loadkelas",
table: "#example2",
fields: [ {
label: "Nama :",
name: "nama"
}, {
label: "Fasilitas :",
name: "fasilitas",
type: "textarea"
}, {
label: "Images:",
name: "files[].id",
type: "uploadMany",
display: function ( file_id, counter ) {
return '<img src="'+table2.file( 'files', file_id ).web_path+'"/>';
},
noFileText: 'No images'
}
]
} );
var table2 = $('#example2').DataTable( {
dom: '<"col-sm-12 chat"B><"col-sm-12"><"clear"><"col-sm-6"l><"col-sm-6 pull-right"Tf><rt><"col-sm-6"i><"col-sm-6"p>',
ajax: "Ajax/loadkelas",
columns: [
{ data: "id" },
{ data: "nama" },
{ data: "fasilitas"},
{
data: "files",
render: function ( d ) {
return d.length ?
d.length+' image(s)' :
'No image';
},
title: "Image"
}
],
select: true,
buttons: [
{
extend: "create",
text:"<span><i class='fa fa-plus'> Tambah Data </i><span>",
editor: editor2,
className:"btn btn-success btneditor"},
{
extend: "edit",
text:"<span><i class='fa fa-edit'> Edit Data </i><span>",
editor: editor2,
className:"btn btn-warning btneditor" },
{
extend: "remove",
text:"<span><i class='fa fa-trash'> Hapus Data </i><span>",
editor: editor2,
className:"btn btn-danger btneditor" }
]
} );
Answers
Could you confirm if you are using any of our server-side libraries, and if so, which platform and what version of them?
Thanks,
Allan
i'm using newest php library version
but my editor version 1.5.5
thanks,
can i send you private link ?
You are using the Editor 1.9.2 libraries with the 1.5.5 client-side code? I'd suggest switching to 1.9.2 with both!
Regarding a PM, yes, click on my forum user name above and then click the "send message" button.
Allan