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])
});
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742282793a4414797.html
评论列表(0条)