Angularjs 如何在ionic中将映像作为文件发送到服务器
我正在使用ionic和ngCordova摄像头插件来调用我的摄像头,并且我正在以base64格式获取我的图像。我不需要保存图像,但我需要发送图像以用作base64。我需要将其作为文件格式发送。是否有任何方法将图像作为文件发送,以服务于我的备份is c# 这是我的html看起来像Angularjs 如何在ionic中将映像作为文件发送到服务器,angularjs,image,ionic-framework,cordova-plugins,ngcordova,Angularjs,Image,Ionic Framework,Cordova Plugins,Ngcordova,我正在使用ionic和ngCordova摄像头插件来调用我的摄像头,并且我正在以base64格式获取我的图像。我不需要保存图像,但我需要发送图像以用作base64。我需要将其作为文件格式发送。是否有任何方法将图像作为文件发送,以服务于我的备份is c# 这是我的html看起来像 <img ng-show="imgURI !== undefined" ng-src="{{imgURI}}"> <img ng-show="imgURI === undefined"
<img ng-show="imgURI !== undefined" ng-src="{{imgURI}}">
<img ng-show="imgURI === undefined" ng-src="http://placehold.it/250x250">
<button class="button" ng-click="takePicture()">Take Picture</button>
在我的imageData中,我有base64值。是否有办法将$scope.imgURI转换为文件,以便我能够发送我的图像以提供服务。为什么不使用
Camera.DestinationType.file\u URI
,而不是Camera.DestinationType.DATA\u URL
,作为DestinationType
这样,您将在设备文件系统上获得一个文件;那么我想把这个文件上传到你的服务器应该很容易
然后,如果您的设备上不再需要该文件,您可以将其删除
如果您更喜欢处理base64,您可以检查模块,它将base64数据上传到服务器…是的,您是对的,我看到了这个选项,但在使用这个**$cordovaCamera.getPicture(选项)之后,然后(函数(imageURI){var image=document.getElementById('myImage');image.src=imageURI;},**我不知道该向服务器发送哪一个我的文件在这里我是爱奥尼亚的新手请帮助我使用
Camera.DestinationType.file\u URI
,在imageURI
中,您可以获得base64格式的图像内容。在那里,您应该调用angular-base64-upload模块传递base64数据和您的服务器url。我面临io问题当我有文件URI时,我无法显示图像,但在android中工作正常
$scope.takePicture = function(){
var options = {
quality: 50,
destinationType: Camera.DestinationType.DATA_URL,
sourceType: Camera.PictureSourceType.CAMERA,
allowEdit: true,
encodingType: Camera.EncodingType.JPEG,
targetWidth: 250,
targetHeight: 250,
popoverOptions: CameraPopoverOptions,
saveToPhotoAlbum: false,
correctOrientation:true
};
$cordovaCamera.getPicture(options).then(function(imageData) {
console.log(imageData);
$scope.imgURI = "data:image/jpeg;base64," + imageData;
}, function(err) {
// error
});
};
}, false);