Angularjs的FileConstructor不是构造函数' [英] Angularjs 'FileConstructor is not a constructor'

查看:154
本文介绍了Angularjs的FileConstructor不是构造函数'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


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

Issue: Error: FileConstructor is not a constructor (evaluating 'new File([blob], "filename.png")')

我看到了这个问题替代方案用于safari的File()构造函数但是没有任何值得关注的替代方案。

I saw this question Alternative for File() constructor for safari but there weren't any alternatives worth looking at.

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

Is there anyway to work around this using Ionic Framework on IOS?

Javascript

a = Base64图片。

a = Base64 image.

 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});  


推荐答案

我在文件和Safari方面遇到同样的问题。
经过一番研究后,我发现解决方案似乎对我有用...希望它对你有用:

I'm facing the same issue with File and Safari. After some research I found a solution that seems to work for me... hope it will be useful for you:

而不是使用 新文件 ,我将名称 lastModifiedDate 字段附加到blob。

Instead of using new File, i append name and lastModifiedDate fields to the blob.

 blob.name = "filename.png";
 blob.lastModifiedDate = new Date();

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

It is not a file, but you can use it like it was...

这篇关于Angularjs的FileConstructor不是构造函数'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆