On 9/29/07, Tomas J. Fulopp <tomi@vacilando.org> wrote:
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
Yes, that was clearly wrong. Probably just file_create_url() would be better.
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.
This looks good, but don't forget to try it without Clean URLs.
Cheers,
Tomas
Cog Rusty wrote: On 9/21/07, Tomas J. Fulopp <tomi@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