Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8206485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T08:41:19+00:00 2026-06-07T08:41:19+00:00

There’s something arcane going on with my custom CKEditor uploader. The image or whatever

  • 0

There’s something arcane going on with my custom CKEditor uploader. The image or whatever file I try to upload to the server is correctly uploaded but no matter what I do it’s link won’t show up in the editor. It looks like the callback to CKEditor in my upload_file.html view doesn’t work as it should. The documentation of CKEditor is really sparse about these things, so I could really use some guidance here.

In my controller I have the following upload function:

def upload_file():
    upload = request.vars.upload
    if upload != None:
        if hasattr(upload, 'file'):
            old_filename = upload.filename
            new_filename = db.files.uploaded_data.store(upload.file, upload.filename)
            result = db.files.insert(filename = old_filename,
                                     uploaded_data = new_filename,
                                     created_on = datetime.today())
            if not result:
                message = T('An error has occured during upload.')
                url = ''
            else:
                message = T('File uploaded succesfully.')
                url = URL(r = request, f = 'download', args = new_filename)
            return dict(form = None, cknum = request.vars.CKEditorFuncNum, url = url, message = message)
        else:
            raise HTTP(401, T('Upload is not proper type.'))
    else:
        form = SQLFORM(db.files, fields = ['uploaded_data'])
        upload = request.vars.uploaded_data
        if upload != None:
            form.vars.filename = upload.filename
            form.vars.created_on = datetime.today()
        if form.process().accepted:
            response.flash = T('File uploaded successfully!')
        elif form.errors:
            response.flash = T('form has errors')
        else:
            response.flash = T('please fill out the form')
        return dict(form = clean_form(form))

The view for this function looks like this:

{{if form != None:}}
    {{extend 'layout.html'}}
    {{=form}}
{{else:}}
    <html>
        <body>
            <script type="text/javascript">
                window.opener.CKEDITOR.tools.callFunction({{=cknum}}, '{{=url}}', '{{=message}}');
            </script>
        </body>
    </html>
{{pass}}

I have a test view with a form containing several textareas all of which are properly converted to editors:

{{extend 'layout.html'}}
<script type="text/javascript">
    CKEDITOR.config.filebrowserBrowseUrl = "{{=URL(request.application, c='default', f='upload_file')}}";
    CKEDITOR.config.filebrowserUploadUrl = "{{=URL(request.application, c='default', f='upload_file')}}";
    CKEDITOR.config.filebrowserWindowHeight = '60%';
    CKEDITOR.config.filebrowserWindowWidth = '70%';
</script>
{{=form}}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T08:41:21+00:00Added an answer on June 7, 2026 at 8:41 am

    I finally found the solution. There’s a mistake in the view of the upload_file function.

    window.opener.CKEDITOR.tools.callFunction({{=cknum}}, '{{=url}}', '{{=message}}');
    

    should be rewritten to this:

    window.parent.CKEDITOR.tools.callFunction({{=cknum}}, '{{=url}}', '{{=message}}');
    

    I copied the first version, which caused me quite a lot of headache, from web2pyslices, so I write this answer here in the hope that it will help others trying to integrate CKEditor with Web2py.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There is a text file with 1,000,000 lines of code floating around and Ctrl+F
There is something I miss with the notion of Synchronizing code in Android. Scenario
There is something strange happening. Param interceptor is the one in charge to take
There is a moment in my app, that I need to force to show
There is a column that exists in 2 tables. In table 1, this column
There's a Rails 3.2.3 web application which doesn't use any database. But in spite
There is a directed graph having a single designated node called root from which
There are two intents on the receiver side which are called from the same
There are nice SO question and answers about this issue, but these options didn't
There are two table s : one is the master and one the detail

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.