作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在上传 html 5、base64 图像进行解析时遇到问题。我创建了几个解析用户和一个 profile_pic 列。此外,我还添加了 cordovacamera 插件来从图库中选择图像并显示它,但我现在想将图像上传到当前用户的 profile_pic 列。
$scope.takePicture = function(){
var options = {
quality: 100,
destinationType: Camera.DestinationType.DATA_URL,
sourceType: Camera.PictureSourceType.PHOTOLIBRARY,
encodingType: Camera.EncodingType.JPEG
}
$cordovaCamera.getPicture(options)
.then(function(data){
console.log('camera date: '+ angular.toJson(data));
$scope.pictureUrl = 'data:image/jpeg;base64,' + data;
var currentUser = Parse.User.current();
currentUser.set("profile_pic", data);
currentUser.save();
}, function(error) {
console.log('camera error: '+ angular.toJson(data));
});
};
是否可以这样做或者是否有其他我可以使用的方法?我能够成功检索列中的图像并显示用户个人资料图片,但是我需要一种上传方法。
var currentUser = Parse.User.current();
currentUser.fetch().then(function (fetchedUser) {
var name = fetchedUser.getUsername();
var loca = fetchedUser.get('location');
var propic = fetchedUser.get('profile_pic');
var proimage = propic.url();
$scope.username = name;
$scope.location = loca;
$scope.profilepic = proimage;
});
最佳答案
完整源代码在这里 https://github.com/aaronksaunders/dcww/blob/master/www/js/services.js#L33
但基本概念是创建一个文件对象来保存到用户对象中的特定列。
var imageFile = new Parse.File("mypic.jpg", {base64: _params.photo});
imageFile.save().then(function(_f) {
var currentUser = Parse.User.current();
currentUser.set("profile_pic", data);
return currentUser.save();
}).then(function(_user){
return _user;
}, function(_error){
console.log(_error);
};
关于javascript - 如何上传个人资料图片来解析ionic框架,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32555239/
我有以下正则表达式 /[a-zA-Z0-9_-]/ 当字符串只包含从 a 到z 大小写、数字、_ 和 -。 我的代码有什么问题? 能否请您向我提供一个简短的解释和有关如何修复它的代码示例? //var
我是一名优秀的程序员,十分优秀!