新手问题 求助 ,上传照片出现 RequestURITooLarge 错误

liguangsong · 2015年08月17日 · 最后由 liguangsong 回复于 2015年08月18日 · 1934 次阅读
function save_notes(image){
    $.ajax({
        url:"/save_notes",
        data:{
            image:image,
            text:localStorage.getItem("post_text")||""
        },
        success:function(){

        },
        error:function(){

        }
    })
}

本地测试出现

ERROR WEBrick::HTTPStatus::RequestURITooLarge 
ERROR TypeError: can't convert nil into an exact number

感觉应该设定允许上传的文件最大范围,但不知道怎么实现

用 POST

@rei 好的,用 post 有最大范围么

@rei 用 post 后出现错误 Can't verify CSRF token authenticity

#4 楼 @liguangsong 可能默认加载的 jquery-ujs 被去掉了,看看 application.js

https://github.com/rails/jquery-ujs

@rei 非常感谢🙏

@rei 我的 application 里有 jquery-ujs,😢😢

@rei skip_before_filter :verify_authenticity_token, :only => [:save_notes] 后就好了,但是这样做会不会不安全

需要 登录 后方可回复, 如果你还没有账号请 注册新账号