1

I want to display a Highcharts Graph from a chooseable csv File, for this i need it's path.

I have this very simple input which looks like this:

<div class="form-group">
    <label for="file">Choose File</label>
    <input type="file" id="file (change)="function($event.target.files)">
</div>

Now, is there any possibility to get the files path from this input? Are there other ways to let the user choose a file and get its path?

J.Doe
  • 586
  • 2
  • 8
  • 30
  • 2
    Looks like you took the code from https://stackoverflow.com/questions/47936183/angular-file-upload. Why not follow the rest of the answer? – Guillaume CR Sep 04 '19 at 13:41
  • I want the path of the uploaded file. I think the other answer is just for uploading a file but doesn't describe how to find out it's path. – J.Doe Sep 04 '19 at 13:45
  • 1
    in that answer, `$event.target.files` seems to contain the filenames – Guillaume CR Sep 04 '19 at 13:48

1 Answers1

1

Source:

How to get full path of selected file on change of <input type=‘file’> using javascript, jquery-ajax?

For security reasons browsers do not allow this, i.e. JavaScript in browser has no access to the File System, however using HTML5 File API, only Firefox provides a mozFullPath property, but if you try to get the value it returns an empty string:

$('input[type=file]').change(function () {
    console.log(this.files[0].mozFullPath);
});

http://jsfiddle.net/SCK5A/

So don't waste your time.

edit: If you need the file's path for reading a file you can use the FileReader API instead. Here is a related question on SO: Preview an image before it is uploaded.

KLTR
  • 1,263
  • 2
  • 14
  • 37