def upload_img(): ck_num = request.values.get('CKEditorFuncNum') upload_img = request.files.get('upload') img_name = generate_upload_name() + op.splitext(upload_img.filename)[-1] img_path = op.join(op.join(media_path, img_name)) upload_img.save(img_path) img_url = media_url + '/' + img_name return ''' <script> window.parent.CKEDITOR.tools.callFunction(%(ck_num)s, "%(path)s", "上传成功"); </script> ''' % dict(ck_num=ck_num, path=img_url)
def upload_img(): ck_num = request.values.get('CKEditorFuncNum') up_img = request.files.get('upload') uploaded_name = generate_upload_name() + os.path.splitext(up_img.filename)[-1] uploaded_path = os.path.join(media_path, uploaded_name) up_img.save(uploaded_path) img_url = '{}/{}'.format(media_url, uploaded_name) return ''' <script> window.parent.CKEDITOR.tools.callFunction(%(ck_num)s, "%(path)s", "上传成功"); </script> ''' % dict(ck_num=ck_num, path=img_url)