Uncaught Unknown file table name - On page reload
Uncaught Unknown file table name - On page reload
Hello all,
I have the following problem:
We use a DataTable with Editor to upload images.
This works fine so far. Important: It is not mandatory to upload all images.
As soon as I uploaded one photo out of 5, the table shows the one image, while for the others "No Photo" is shown as DefaultContent.
Now when I reload the table, I always get the following error:
Uncaught Unknown file table name
But this only occurs if the first image field of the table is empty.
So assumption:
1st photo is uploaded, but 2-3-4-5 are not --> no error, the table displays the photo in the 1 photo column and sets the DefaultContent in the other columns correctly.
2nd photo is uploaded, 1-3-4-5 but not --> said error appears.
So it seems to always refer to the first photo whether the table loads or not.
Attached is a code snippet to illustrate exactly how it looks:
JS File:
//JS Editor:
{
"label": "Seitlich links:",
"name": "foto",
"type": "upload",
display: function ( file_id ) {
if(file_id){
let file_details = editor.file('table_foto', file_id).web_path.split('/');
let file_name = file_details.pop();
return '<img style="max-width:90px;" src="'+site_url+'picture/pic37/'+file_name+'">';
}
},
clearText: "Löschen",
noImageText: 'Kein Foto',
noFileText: 'Nichts hochgeladen',
uploadText: 'Foto aufnehmen',
dragDrop: false,
},
//JS Table:
{
"data": "foto",
render: function ( file_id ) {
if(file_id){
let file_details = editor.file('table_foto', file_id).web_path.split('/');
let file_name = file_details.pop();
return '<a href="'+site_url+'picture/pic37/'+file_name+'" download> Bild herunterladen </a>';
}
},
defaultContent: "Kein Foto",
},
PHP Model:
Field::inst( 'foto' )
->upload( Upload::inst( $SERVER['DOCUMENT_ROOT'].'/assets/Pictures/fotos/ID'.md5(uniqid(mt_rand(), true)).'.EXTN_' )
->db( 'table_foto', 'id', array(
'name' => Upload::DB_FILE_NAME,
'size' => Upload::DB_FILE_SIZE,
'web_path' => Upload::DB_WEB_PATH,
'system_path' => Upload::DB_SYSTEM_PATH
) )
->validator( Validate::fileSize( 150000000, 'Fotos müssen kleiner als 150Mb sein.' ) )
->validator( Validate::fileExtensions( array( 'png','jpeg','jpg', 'gif' ), "Laden Sie ein Foto hoch." ) )
)
->setFormatter( Format::ifEmpty( null ) ),
Note:
I do not call the directory in which the photo is located directly, but via a controller to avoid unauthorized access.
If the part "pictures/pic37" should cause confusion. This part works.
I would be very grateful for any help!
Many greetings!
Answers
Hi,
Can you use the debugger to give me a trace please - click the Upload button and then let me know what the debug code is.
Thanks,
Allan
Hi Allan,
thanks for the answer.
I have pasted the code snippet for the debugger once in the Console and run it on the page with the DataTable. After that, the "DataTables Debugger" window has opened. But as soon as I click on "Table information" or "Upload configuration data" the following error messages appear:
I tried to run the debugger on other pages where I have included a DataTable and where no problems occur at all, but the same errors appear here as well.
Do you know why this is happening and could this be the cause of my original problem?
Thanks!
Possibly, that doesn't sound good. Are you able to link to your page, please, so we can take a look?
Colin
Hi Colin,
the problem is that the site is completely restricted by a rights and roles concept and I'm unfortunately not allowed to simply create an account for you.
Would it be possible to discuss/show this in a live session, e.g. via Skype, Teams or Discord? If so, I would of course also acquire the support credits for this.
Many greetings!
interesting! It could be related, but I'm not certain. It sounds like you don't have jQuery as a browser global - perhaps you are using a bundler or RequireJS?
Could you show me the JSON response from the server (which is the main piece of information I was looking for from the debugger upload) - you can send me a PM if you prefer not to make the data public (click my name above and then "Send Message")? This tech note shows how to get the response from the server to an Ajax request if you aren't sure.
If we don't get anywhere with this, then yes, a live session is probably the next step!
Regards,
Allan
Hey Allan,
thanks for your support. I have sent you a PM!