【发布时间】:2016-05-17 17:34:03
【问题描述】:
我已经编写了允许用户将图像上传到 firebase 数据库的代码。该代码基本上引用了节点'images,然后将图像设置为子节点url。但是我收到以下消息。
Firebase.set failed: First argument contains undefined in property 'images.url'
关于为什么会发生这种情况的任何线索?我的代码如下。
var theBigWeddingBook = angular.module('theBigWeddingBook');
theBigWeddingBook.controller('WeddingBookCtrl', function($scope, $firebase, Upload) {
var ref= new Firebase('https://the-big-wedding-book.firebaseio.com/');
var images = $scope.file;
$scope.submit = function() {
ref.child('images').set({url : images}).then(function(url) {
console.log('Image Uploaded!');
}).catch(function(error) {
console.log(error);
})
}
});
【问题讨论】:
-
您的图像变量的价值是多少?
-
值为通过ng文件上传表单加载的图片...所以是'ng-model="images"'
-
Firebase 不支持图片,但如果您将图片转换为 base64 字符串,则可以保存它们。
-
谢谢,我明天试试
标签: angularjs firebase angularfire firebase-realtime-database