Get Absolute Path (i.e., Current Working Directory) from Root

A JavaScript instruction:

Code:
   var path = document.location.pathname;

. . .embedded in a html file will assign a value to [font="Courier New"]path[/font], for example:

Code:
   /htdocs/Photolib/ThisWeek/


What I need ( . . .not the server root) is the absolute path from the system root, e.g.:

Code:
   /usr/local/www/vhosts/archaxis.net/htdocs/Photolib/ThisWeek/


Perl can do this:

Code:
   use Cwd;
   my $path = getcwd;

. . .and return the assigned value for [font="Courier New"]$path[/font] as:

Code:
   /usr/local/www/vhosts/archaxis.net/cgi-bin/perl

Note that the returned value of [font="Courier New"]$path[/font] is the directory of [font="Courier New"]cgi-bin[/font] where the Perl script resides . . .not what I need!

I have an application that needs to create subdirectories of a current working directory. Also, a subdirectory could become a parent of a future subdirectory . . .and so on. Each subdirectory will contain a [font="Courier New"]README.html[/font] file that is auto-executed by the Apache http server's display of the directory's index list. This html file contains some file manipulation functions, including one to create a new subdirectory.

I need to capture the path of the current directory containing an individual [font="Courier New"]README.html[/font] file, and pass the path as a parameter to a Perl script in cgi-bin. This Perl script will prompt the user for a user id., directory name, file permissions, etc. Then the name for the new subdirectory specified by the user can be concatenated to the [font="Courier New"]$path[/font] string, and the new subdirectory can be created in the named subdirectory, e.g."

Code:
   /usr/local/www/vhosts/archaxis.net/htdocs/Photolib/ThisWeek/[B]Tuesday[/B]

This seems like a simple thing to do . . .certainly within OS/400, Unix shell, etc., but I cannot find an example of a simple line of JavaScript code to produce the absolute path string as per Perl.

(I'm sure that I can write a half-page of code replete with regex'es, sed's, chomps, cat's, ad nauseam, but isn't there a simple way to do this?)

Suggestions will be greatly appreciated, :)

Ron W.
 
You cannot know full system path with JS.
Its client-side part of app, so client dont know where is server root (unless you give client $ENV{DOCUMENT_ROOT} from perl or php)
 
Yeah . . .after getting some sleep this morning, It finally dawned on me that the http server is stateless. By far, most of my experience over the past thirty-five years has involved writing dynamic interfaces.


Today, I designed and coded a straightforward . . .fairly simple solution. I will post the code ASAP, but Friday approaches.
 
Back
Top