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... :)

0

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.