[development] base_path() not returning path to Drupal root

Cog Rusty cog.rusty at gmail.com
Fri Sep 21 14:23:24 UTC 2007

On 9/21/07, Tomas J. Fulopp <tomi at vacilando.org> wrote:
> I have one other question I am pondering for a crazy long time - I
> wonder if it's a bug in the core...?
> An user has Drupal installed in www.example.com/foldera/folderb/ and in
> there a files folder ( thus www.example.com/foldera/folderb/files/ )
> In my module, I need to determine the path to the 'files' folder
> relative to the domain name (example.com)
> So I've used file_directory_path() .. that gave me just 'files'.
> Then I've used base_path() hoping that it would give me
> /foldera/folderb/ this way
> base_path() . file_directory_path()
> but the result was
> /files

file_directory_path() is a disk file path relative to drupal, and
base_path() is an URL path. So, using base_path() .

- when I access the site as http://example.com/foldera/folderb it
gives me "/foldera/folderb/files"
- when I access the site as http://subdomain.example.com it give me "/files"

But because it is an URL path, it is the same place and it works in
both cases as far as the web browser is concerned. Is there a reason
for your module to know the physical disk paths?

> I see this issue was discussed at length at
> http://lists.drupal.org/archives/support/2006-03/msg00042.html but there
> are no clear conclusions, and anyway, that's a thread from March 2006.
> So I wonder whether there is a clean solution for this.
> I'm on Drupal 5.2, btw.
> Tomas

More information about the development mailing list