0

I'm trying to find actual path of my working directory using javascript. I read from this post How to get the absolute path of the current javascript file name

<script>
  alert(location.pathname);  // /tmp/test.html
  alert(location.hostname);  // localhost
  alert(location.search);    // ?blah=2
  alert(document.URL);       // http://localhost/tmp/test.html?blah=2#foobar
  alert(location.href);      // http://localhost/tmp/test.html?blah=2#foobar
  alert(location.protocol);  // http:
  alert(location.host);      // localhost
  alert(location.origin);    // http://localhost
  alert(location.hash);      // #foobar
</script> 

But none of them that I have been looking for because I wanna find the path for example "C:/xampp/htdocs/myCurrentDirectory". So How to do this...?

Thanks in advance... :)

Community
  • 1
  • 1
Maryadi Poipo
  • 1,418
  • 8
  • 31
  • 54

1 Answers1

3

You can't.

Any connection between a URL and a file path is handled entirely internally by the HTTP server (and may not exist at all). Nothing about that relationship is exposed to the client, so client-side code can't know anything about it.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335