def upload(self, name=None, path=None, folder='upload',\
            allowed_extensions=None, max_size=None):
        """
        ckeditor upload method
        :name: the app name or blueprint name
        :path: the upload path
        :allowed_extensions: allowed file extensions
        :max_size: the max size of uploaded file
        """
        error = ''
        url = ''
        callback = request.args.get("CKEditorFuncNum")

        if request.method == 'POST' and 'upload' in request.files:
            fileobj = request.files['upload']
            fname, fext = os.path.splitext(fileobj.filename)
            if allowed_extensions and \
                fext not in allowed_extensions:
                    error = '%s not in the allowed extensions!' % fext
                    return error
            rnd_name = '%s%s' % (self.gen_rnd_filename(), fext)

            if not path:
                filepath = os.path.join(name.static_folder, 'upload', rnd_name)
            else:
                filepath = path
                app.add_url_rule('/ckupload/<filename>', 'uploaded_file',
                        build_only=True)
                app.wsgi_app = SharedDataMiddleware(app.wsgi_app, {
                    '/ckupload/': path
                })

            dirname = os.path.dirname(filepath)
            if not os.path.exists(dirname):
                try:
                    os.makedirs(dirname)
                except:
                    error = 'path <%s> not exist!' % filepath
            elif not os.access(dirname, os.W_OK):
                error = 'path <%s> not writable' % filepath
            if not error:
                fileobj.save(filepath)
                url = url_for('.static', filename=('upload', rnd_name) % '%s/%s')
                # if not path:
                #     url = url_for('.static', filename='%s/%s' % (folder, rnd_name))
                # else:
                #     url = url_for('.uploaded_file', filename='%s/%s' % (folder, rnd_name))
        else:
            error = 'post error'

        res = """
                <script type="text/javascript">
                    window.parent.CKEDITOR.tools.callFunction('%s', '%s', '%s');
                </script>
             """ % (callback, url, error)

        response = make_response(res)
        response.headers["Content-Type"] = "text/html"
        return response
dataset/ETHPy150Open neo1218/flask-ckeditor/flaskckeditor.py/CKEditor.upload/swapped operands of `%`