Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get path directory from FileReader()?

Hi i have these codes to read the file the user has uploaded:

function readURL(input) {
  if (input.files && input.files[0]) {
    var reader = new FileReader();

    reader.onload = function(e) {
      $('#myImg').attr('src', e.target.result);
    }

    reader.readAsDataURL(input.files[0]);
  }
}

And the output is a whole chunk of data:

enter image description here

Is there any way i can get the path from the data? for example C:\Users\blackLeather\Desktop

If no,is there another way to get the image directory without having to add into another folder?

like image 886
Black Leather Avatar asked Dec 13 '18 09:12

Black Leather


People also ask

How to get path from file name in Java?

File getAbsolutePath() method in Java with Examples The getAbsolutePath() method is a part of File class. This function returns the absolute pathname of the given file object. If the pathname of the file object is absolute then it simply returns the path of the current file object.

What does FileReader do in Javascript?

The FileReader object lets web applications asynchronously read the contents of files (or raw data buffers) stored on the user's computer, using File or Blob objects to specify the file or data to read.


1 Answers

Is there any way i can get the path from the data?

No. None at all. That information is not provided to the JavaScript layer by the browser, for security reasons.

like image 117
T.J. Crowder Avatar answered Sep 21 '22 21:09

T.J. Crowder