I am trying to catch a file using PHP
and AngularJS
. However, I cannot send the file successfully using AngularJS
.
HTML
<input type="file" ng-model="image" onchange="angular.element(this).scope().sendFile(this);">
Angular function
$scope.sendFile = function(image) {
var postData = {
image: image.files[0]
};
$http.post($rootScope.root + '/test/image', postData).success(function(data) {
console.log(data);
});
}
As of now, the image.files[0]
is an array
of information about the file. Location, size and so on.
How do I pass the actual file?
也许您可以通过其源访问图像,将其转换为base64,然后将其简单地作为参数传递
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.