Hello forum
I'm trying to implement image upload functionality to the Rich Text Editor by following the example given in this blog post:
https://apex.oracle.com/pls/apex/germancommunities/apexcommunity/tipp/6401/index-en.html
The end product will be a documentation management system, where the editing functionality is crucial.My environment: APEX 18.2, ORDS 18.3, Weblogic 12.2.1.3.
I have already made the RESTful service to provide the direct image link from the BLOB, as described in the blog article - everything works as described in the blog post. But I'm facing two challenges with the example given:
- 1. The submit button in the Image Upload page allows submitting the page, even if the user has not chosen any file, causing a null BLOB to be created. Upload should only be allowed, if the user has actually chosen a file. How can I modify the Submit button, so it takes this into consideration?
- 2. Next – again the Submit button in the Image Upload page. When launched, the URL of this page looks like this (in my setup):
https://(server)/ords/bska/apex/f?p=101:2:10061186388535::&CKEditor=P1_NEW&CKEditorFuncNum=1&langCode=en
In the Function and Global Variable Declaration, in the example, a piece of JavaScript is given:
function returnFileUrl( pId ) {
var funcNum = getUrlParam( 'CKEditorFuncNum' ),
// Achtung: hier anpassen!
fileUrl = "/ords/bska/apex/apex_bska_001/image/download/" + pId;
function getUrlParam( paramName ) {
var reParam = new RegExp( '(?:[\?&]|&)' + paramName + '=([^&]+)', 'i' );
var match = window.location.search.match( reParam );
return ( match && match.length > 1 ) ? match[1] : null;
}
window.opener.CKEDITOR.tools.callFunction( funcNum, fileUrl );
window.close();
}
The big problem is, that this JavaScript fails after having submitted this page once, as the URL looks like this after a Submit:
https://(servername)/ords/bska/apex/f?p=101:2:10061186388535::NO:::
The getUrlParam fails with this URL, because the reParam returns "CKEditorFuncNum=1", because this is part of the URL. But after doing a Submit, this is no longer part of the URL. For that reason, the getUrlParam function returns null – which means, that you can only return existing images, if you don't upload an image – ie. submit the page. This can hardly be the intention. How do you Submit without altering window.location.search?
Thanks in advance