我无法在混合移动应用上使用Angular和Ionic将图像上传到Parse Server。我使用的是最新版本的Parse Sever和Parse Javascript SDK。我总是收到错误130:文件上传无效。
我相信我必须将图像编码为64,我是否正确? 这是我的上传代码:
$scope.doSignUp = function(){
// if (true)
// {
// $scope.image_error = "* Por favor selecciona una imagen";
//}else{
var file = "";
window.plugins.Base64.encodeFile($scope.collection.selectedImage, function(base64){
file = base64;
});
var imageFile = new Parse.File("image.png", { base64: file },"image/png");
imageFile.save().then(function() {
var user = new Parse.User();
user.set("username", $scope.user.username);
user.set("password", $scope.user.password);
user.set("email", $scope.user.email);
user.set("picture", imageFile);//getting file need url
user.signUp(null, {
success: function(user) {
$state.go('app.home');
},
error: function(user, error) {
// Show the error message somewhere and let the user try again.
alert("Error: " + error.code + " " + error.message);
}
});
}, function(error) {
console.log("Error");
console.dir(error);
alert("Error: " + error.code + " " + error.message);
});
//$state.go('app.feeds-categories');
//}
};
答案 0 :(得分:0)
你试过吗?
alert(document.location.pathname.match(/[^\/]+$/)[0]);