javascript - get file object using full path - Stack Overflow

is there a way to get a file object using the directory full path of the file itself? this piece of cod

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
Add a ment  | 

2 Answers 2

Reset to default 4

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742282793a4414797.html

相关推荐

  • javascript - get file object using full path - Stack Overflow

    is there a way to get a file object using the directory full path of the file itself? this piece of cod

    19小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信