【发布时间】:2015-03-13 19:09:04
【问题描述】:
我正在尝试使用ionic $cordovaFile 插件将图片从我的应用上传到服务器,以下是我的代码
$cordovaCamera.getPicture(options).then(function(imageData) {
$scope.imgURI = "data:image/jpeg;base64," + imageData;
options = {
fileKey: "avatar",
fileName: "image.png",
chunkedMode: false,
mimeType: "image/jpeg"
}
$cordovaFile.uploadFile('http://localhost:3001/images/',$scope.imgURI, options)
.then(function(result){
console.log("Code = ok");
}, function(error){
console.log("Code = " + error);
}, function(progress){
})
}, function(err) {
//An error occured. Show a message to the user
});
这是我在页面中添加它的方式
<script src="js/ng-cordova.min.js"></script>
<script src="cordova.js"></script>
问题是当我运行项目时,它提示我使用相机,当我得到图片时,我的控制台中出现以下错误
[phonegap] [console.error] Error: Can't find variable: FileTransfer
[phonegap] uploadFile@http://10.1.1.4:3000/js/ng-cordova.min.js:7:24346
[phonegap] http://10.1.1.4:3000/js/controllers/picture_ctrl.js:32:36
...
我使用phonegap developer app 作为模拟器。
是什么原因?
【问题讨论】:
标签: cordova ionic-framework cordova-plugins