admin管理员组文章数量:1395752
I was trying to create file object with
var file = File("path/to/some/file");
as remended in the link .
However, the bellowing error occurs
Uncaught TypeError: Failed to construct 'File': Please use the 'new' operator, this DOM object constructor cannot be called as a function.
How do I fix it and link a file path to the file object in javascript?
I was trying to create file object with
var file = File("path/to/some/file");
as remended in the link https://developer.mozilla/en-US/docs/Extensions/Using_the_DOM_File_API_in_chrome_code.
However, the bellowing error occurs
Uncaught TypeError: Failed to construct 'File': Please use the 'new' operator, this DOM object constructor cannot be called as a function.
How do I fix it and link a file path to the file object in javascript?
Share Improve this question asked Jul 6, 2015 at 19:11 Elliscope FangElliscope Fang 3512 gold badges4 silver badges9 bronze badges 2- Well, did you try to use new File("..") instead ? Did it work? – Gonzalo.- Commented Jul 6, 2015 at 19:12
- 1 Are you writing chrome code for a Firefox extension? From the first three sentences of that page: "If you want to use the DOM File API in chrome code, you can do so without restriction. In fact, you get one bonus feature: you can create File objects specifying the path of the file on the user's puter. This only works from privileged code, so web content can't do it." – apsillers Commented Jul 6, 2015 at 19:38
1 Answer
Reset to default 3That's indicating that you should call the constructor like this:
var file = new File("path/to/some/file");
本文标签:
版权声明:本文标题:javascript - Uncaught TypeError: Failed to construct 'File': Please use the 'new' operator, this 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744715332a2621368.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论