admin管理员组文章数量:1332395
is there a way to get a file object using the directory full path of the file itself? this piece of code wont work:
var file1 = new File("D:\\path\\to\\file\\file.txt");
I need to get the file object since I have a function that has a file object as its parameter.
bryan
is there a way to get a file object using the directory full path of the file itself? this piece of code wont work:
var file1 = new File("D:\\path\\to\\file\\file.txt");
I need to get the file object since I have a function that has a file object as its parameter.
bryan
Share Improve this question asked Aug 24, 2015 at 4:44 overmindovermind 4771 gold badge8 silver badges18 bronze badges 1-
2
no. You can't access user's system file through js in a browser. You can however ask him to select it via an
<input type="file">
element – Kaiido Commented Aug 24, 2015 at 4:49
2 Answers
Reset to default 4That would be very tragic if browsers could suddenly start accessing users' file systems without their permission.
I would suggest using <input type="file">
. This way the user chooses which file they will allow the browser to access.
I would suggest you to use: <input type="file" id="fileUpload">
and get the file name using
$('input[type=file]').change(function () {
console.log(this.files[0])
});
本文标签: javascriptget file object using full pathStack Overflow
版权声明:本文标题:javascript - get file object using full path - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742282792a2446402.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论