Angularjs的FileConstructor不是构造函数'

5 javascript angularjs ionic-framework

问题:错误:FileConstructor不是构造函数(评估'new File([blob],"filename.png")')

我在safari中看到了这个问题替代File()构造函数,但没有任何值得关注的替代方案.

无论如何使用IOS上的Ionic Framework来解决这个问题?

使用Javascript

a = Base64图像.

 var blob = new Blob([a], {type: 'image/png'});

        console.log(blob);
        $scope.Issue14 = blob;

       var nfile = new File([blob], "filename.png");

        console.log(nfile);
        $scope.Issue15 = nfile;

       var _file = nfile;

        console.log(_file);
        $scope.Issue16 =  _file;

        $scope.Images.push({"img": _file});  
Run Code Online (Sandbox Code Playgroud)

wrr*_*zag 4

我在 File 和 Safari 中也面临同样的问题。经过一番研究,我找到了一个似乎对我有用的解决方案......希望它对您有用:

我没有使用new File,而是将namelastModifiedDate字段附加到 blob 中。

 blob.name = "filename.png";
 blob.lastModifiedDate = new Date();
Run Code Online (Sandbox Code Playgroud)

它不是一个文件,但您可以像以前一样使用它......