无法使用 angular js 将 base 64 图像发送到服务器

unable to send a base 64 image to server with angular js

我想使用 $http.get

将 base 64 图像发送到服务器端
$http.get(myurl+'?image='+image)

图像变量看起来像:

data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABOYAAAJYCAYAAADG7OkVAAAgAElEQVR4Xuy9CXhV1bn//w0Jmc/JAA51......

但是我在执行 url 时出现 http 错误:400(错误请求)

我认为问题是由于图像变量长度 = 114498

如何使用 angular 发送 base 64 图像?

您必须使用 http post 并假设如果您使用多格式数据则必须使用

        var fd = new FormData();
    fd.append('file', file);
    $http.post(url, fd, {
        transformRequest: angular.identity,
        headers: {'Content-Type': undefined}
    })
    .success(function(){
        //success
    })
    .error(function(){
        //failed
    });

其中文件是您发送到服务器的实际文件