1

i have a piece of code that let's the user see find a file how do i get it to display where it is save eg desktop/folder/file.

my current code is a basic file input that goes like

<input type="file"/>

i want my page to display where the file is saved also on a side not is there a way to display search file results. I look up programing work and my page will show everything that is programing work in its name.

i have not tried anything as i am unsure where to start.

1 Answers1

1

I'm pretty sure you want to get the full file path of a file uploaded via an HTML input element, if not, let me know.

If so, such behavior is intentionally blocked by most browsers, except for firefox. See How to get full path of selected file on change of <input type=‘file’> using javascript, jquery-ajax?. If you want to raed the file, you can use the FileReader class. Alternatively, you can make an object URL to the file object, on the onchange event, simply

var url = URL.createObjectURL(event.target.files[0]);

to use for reading purposes.

wow ow
  • 192
  • 10
  • 1
    thank you for your comment i appreciate the help i am curious if you know how once the user uploads the file if theres a way to let them open it – alandtic dead May 21 '20 at 03:14
  • @alandticdead what do you mean by "open it"? To view the contents, you can fetch the URL using fetch like `fetch(url).then(r => r.text()/*or r.blob() for binary data*/).then(r=> console.log(r));` – wow ow May 21 '20 at 03:18