zoukankan      html  css  js  c++  java
  • 关于 DjangoUeditor 上传图片图片失败,csrf token missing or incorrect 的解决办法

    Forbidden (CSRF token missing or incorrect.): /ueditor/controller/
    [27/Jun/2017 23:49:25] "POST /ueditor/controller/?imagePathFormat=courses%2Fueditor%2F&filePathFormat=courses%2Fueditor%2F&action=uploadvideo&encode=utf-8 HTTP/1.1" 403 2266

      错误原因:get_ueditor_controller() 方法没有csrf保护

      解决办法:

      在ueditor源码中的views.py文件中找到get_ueditor_controller函数,然后添加@csrf_exempt 装饰器

    @csrf_exempt
    def get_ueditor_controller(request):
        """获取ueditor的后端URL地址    """
    
        action=request.GET.get("action","")
        reponseAction={
            "config":get_ueditor_settings,
            "uploadimage":UploadFile,
            "uploadscrawl":UploadFile,
            "uploadvideo":UploadFile,
            "uploadfile":UploadFile,
            "catchimage":catcher_remote_image,
            "listimage":list_files,
            "listfile":list_files
        }
        return reponseAction[action](request)
  • 相关阅读:
    ojdbc14.jar
    Redis
    ftl转成word
    Swagger
    SpringBoot
    条件注解
    Spring SpringMVC MyBatis
    Spring介绍
    Django_mysql表查询
    Django01
  • 原文地址:https://www.cnblogs.com/justbreaking/p/7087864.html
Copyright © 2011-2022 走看看