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

Tomas J. Fulopp tomi at vacilando.org
Sat Sep 29 17:00:09 UTC 2007


Cog,

That was not a solution.
For http://example.com/foldera/folderb
base_path() . file_directory_path()
returns /foldera/folderb/files
only if Drupal is installed in the root of example.com

If Drupal is installed in folderb then
base_path() . file_directory_path()
returns /files
and that means that the full link (in browser) is
http://example.com/files
which is the problem I described.

I am trying Moshe's suggested solution that uses
url(file_directory_path(), NULL, NULL, TRUE)
which generates absolute http paths, which is a drawback, but I think it 
will be the solution.

Cheers,

Tomas



Cog Rusty wrote:
> 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() .
> file_directory_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
>>
>>
>>     
>
>   
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20070929/05a604b4/attachment.htm 


More information about the development mailing list