How to upload image with angularjs

非 Y 不嫁゛ 提交于 2019-12-02 06:56:23

Ok,

I have found the solution by searching deep in SO.

Here is solution:

var profile_pic=picture.files.item(0);
var jsonData=$scope.myobject;
$http({
    url: 'http://localhost/mypro/resource',
    method: "POST",
    headers: {'Content-Type': undefined },
    transformRequest: function (data) {
        var formData = new FormData();
        formData.append("model", angular.toJson($scope.myobject));
        formData.append("profile_pic", picture.files.item(0));

        return formData;
    },
    data: {'myobject' : jsonData,'profile_pic':profile_pic},

Thanx SO :)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!