在离子框架中上传多个

时间:2016-06-20 08:58:35

标签: ionic-framework

我想将多个图片上传到远程服务器, 我尝试cordovaFileTransfer,但我得到错误

  

ReferenceError:未定义fileURL

控制器js

.controller("UploadController", function($scope, $cordovaFileTransfer) {

$scope.upload = function() {
    var options = {
        fileKey: "avatar",
        fileName: "image.png",
        chunkedMode: false,
        mimeType: "image/png"
    };
    $cordovaFileTransfer.upload("api/upload_image", fileURL.substr(fileURL.lastIndexOf('/') + 1) , options).then(function(result) {
        console.log("SUCCESS: " + JSON.stringify(result.response));
    }, function(err) {
        console.log("ERROR: " + JSON.stringify(err));
    }, function (progress) {
        // constant progress updates
    });
}

})

查看

<div ng-controller="UploadController">
    <a class="button button-stable button-block select_cats" ng-click="upload()">Upload Images</a>
</div>

0 个答案:

没有答案