Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get file object using full path

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

like image 797
overmind Avatar asked Sep 26 '22 23:09

overmind


2 Answers

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.

like image 102
Josh Beam Avatar answered Oct 06 '22 01:10

Josh Beam


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])
});
like image 41
Anand Dwivedi Avatar answered Oct 05 '22 23:10

Anand Dwivedi