I am uploading image my code working fine when I use below HTML
<html>
<head></head>
<body>
<form action="http://www.example.com/customers/5832e319f1f1e5cc296e8802" method="post" enctype="multipart/form-data">
Upload: <input type="file" name="upload_image"><br/>
<input type="submit" value="submit">
</form>
<body>
</html>
But when I use below code its not working. I want run my code using AngularJS
HTML:
<input type="file" name="file" id="file"
onchange="angular.element(this).scope().uploadFile(this.files)"/>
JavaScript:
$scope.uploadFile = function (files) {
var fd = new FormData();
fd.append("file", files[0]);
$http.post(properties.customerUploadImage_path + "/" + checkprofile, fd, {
withCredentials: true,
headers: {
enctype: 'multipart/form-data',
}
}).success(function (response) {
console.log(response);
}).error(function (err) {
console.log('sss');
});
};
onchange="$scope.uploadFile(this.files)"
– George yesterday