By audleman on
I'm writing a simple module that will load images from a directory and display one at random. How can I get the path to the base directory on the server that houses my drupal install? This is different from $base_url, which would return a URL.
Thanks,
Kevin
Comments
Long time no hear
Has this ever been resolved? I'm wondering myself how to access the base directory without getting into nasty open_base_dir warnings or file_exists == false conditions writing PHP… Any hints?
Norbert
-- form follows function
Have you tried $base_path ?
Have you tried $base_path ?
http://api.drupal.org/api/global/base_path/6
Thanks, but $base_path
Thanks, but $base_path doesn't anything. The problem is the basepoint of referral: from "outside" the installation has a root of f.e. http://www.myserve.tld and $base_path refers to that 'root'. But PHP uses file read/write paths from the absolute server path, which maybe something like /var/www/domain17/htdocs/
I "solved" the problem with a bad hack in the short term, until I come up with something more universal…
This code is called from within the theme page.tpl.php
Using the URI hardcoded in the theme isn't exactly what I like, but so far it works. If anybody has an idea how to find the current URI of the site (i.e. the full http://www.domain.tld/ thing), let me know :)
Norbert
-- form follows function
realpath("."); should
realpath(".");
should work.
Try it.
Hi
@x3cion that works fine for me ! thanks
thx
This question puzz me 1hour, and it's work now. thx.
<?phprealpath(__FILE__);?>
Contact me to contract me for D7 -> D10/11 migrations.
Use DRUPAL_ROOT constant for
Use DRUPAL_ROOT constant for that.