Reputation: 1478
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... :)
Upvotes: 0
Views: 1937
Reputation: 943569
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.
Upvotes: 3