search

Home  >  Q&A  >  body text

angular.js - Angular $http() 无法发送dataURI数据

使用 ngImgCrop 插件,生成 base64 数据。使用 $http.post() 传递 base64 数据时,发生 414 错误,提示参数太大。
求解决的办法,不想用 原生的 ‘form post’ 请求。在线等...

//*** 省略URL ***//
....
//----参数
_params={image_url:$scope.cropper.croppedImage,name:_form.name}
//----请求
$http({
    method:"POST",
    url:_url,
    params:_params,
    headers:{'Content-Type':'application/x-www-form-urlencoded'},
    transformRequest:angular.identity
});
習慣沉默習慣沉默2744 days ago544

reply all(1)I'll reply

  • 習慣沉默

    習慣沉默2017-05-15 17:01:54

    How did you post it? Up code

    Supplement

    Judging from your code, your approach is to put the parameters after the URL, similar to:

    xxx-url?image_url=mmmm&name=nnnn

    But postit is best to put the parameters in the requestBody. The code is simpler than you think:

    $http({
        method: "POST",
        url: _url,
        data:_params
    });

    That’s good

    reply
    0
  • Cancelreply