search

Home  >  Q&A  >  body text

angular.js - Angular $http() cannot send dataURI data

Use the ngImgCrop plug-in to generate base64 data. When using $http.post() to pass base64 data, a 414 error occurs, indicating that the parameter is too large.
Looking for a solution, I don’t want to use 原生的 ‘form post’ 请求. Waiting online...

//*** 省略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
});
習慣沉默習慣沉默2809 days ago578

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