Editor file upload produces "Can't find variable: Exception" datatables.min.js:315:211
Editor file upload produces "Can't find variable: Exception" datatables.min.js:315:211
Dear all,
for some reasons I have difficulties with the file upload feature of Editor 1.9.2.
I am using Datatables 1.10.20-Bootstrap4 and jQuery 3.4.1.
I used the regular Editor file upload example.
Field::inst( 'image' )
->setFormatter( Format::ifEmpty( null ) )
->upload( Upload::inst($_SERVER['DOCUMENT_ROOT'].'/LRE/php/Helpers/itrack/php/itrackfiles/__ID__.__EXTN__' )
->db( 'system_issues_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" ) ) ),
the JSON response after loaded datatables is:
{"data":[{"DT_RowId":"row_1","id":"1","subject":"test","districtid":"163","region":"2","area":"dLRev","remarks":"no remarks, but now there are","response":"test and more and more","createdby":"ekke","createdat":"2020-04-08 12:29:09","editedby":"ekke","editedat":"2020-04-08 12:29:09","image":"1","active":"1"},{"DT_RowId":"row_2","id":"2","subject":"wrong colour","districtid":"192","region":"4","area":"mobile","remarks":"some businesses do not show a balance","response":"test","createdby":null,"createdat":"2020-04-08 11:03:28","editedby":null,"editedat":"2020-04-08 11:03:28","image":null,"active":"0"}],"options":[],"files":{"system_issues_files":{"1":{"id":"1","filename":"logo-0.jpg","filesize":"40","web_path":"..\/..\/..\/uploads\/logo-0.jpg","system_path":"\/Applications\/MAMP\/htdocs\/gis\/OL212\/LRE\/uploads\/logo-0.jpg"}}}}
When editing the record with Editor and after clicking on the "Upload" button the error "Can't find variable: Exception" with a reference to datatables.min.js:315:211
throw new Exception("Upload feature cannot use `ajax.data` with an object. Please use it as a function instead.");
is shown.
The Network XHR response "blob:http://localgis....." shows the correct selected image.
What am I missing?
Answers
Hi,
Could you show me your client-side Editor initialisation please?
Also I think the
throw new Exception
should actually bethrow new Error
- that is something that has already been fixed, and will be included in Editor 1.9.3. The error message:should have been shown on the console instead of the error about the exception. That error is why I'd like to see your client-side code.
Regards,
Allan
Dear Allan,
this is the editor initialisation:
and this is the table initialisation:
Perfect - thank you. Replace
data: {table: tmptable}
with:and that should do the job.
Regards,
Allan
Dear Allan,
Thank you! The upload works now, however I get immediately after the upload the error message:
with a reference to datatables.min.js:106 and to my editor initialisation (line 75 above):
What is the response from the server to the JSON upload please?
Thanks,
Allan
this is the schema for the system_issues_files where the file() API is stored:
and this is the table with the image field:
and this is the Summary for the BLOB:
Thank you - that actually all looks correct. Are you able to give me a link to your page so I can trace it through please? If you don't want to make it public, send me a PM by clicking my name above and then "Send Message".
It might also be interesting to see the result from modifying your render function for the image in the Editor initialisation to be:
Thanks,
Allan
Thanks Allan,
I sent you a PM regarding this issue and access to the page.
Thanks - I've just sent a reply to your PM.
Allan