In either case, PUBLIC or PRIVATE, the resulting url for a file should look something like:
/path/to/filename
Which should then use the same "http://server/" part as the rest of the site.
urls, generally need to be absolute so that urls can be created that will work irrespective of the setting of "Clean URLs". eg:
Clean URL off: drupal pages are at http://server/?q=drupal/path/page -> the path of these will *always* be "/" since thats the path that hosts the "index.php" file.
Clean URL on: drupal pages are at http://server/drupal/path/page -> your browser thinks the path of the file is in a directory /drupal/path/ .
You can see that the setting of clean urls can change whether a relative link will work or not.
I think it's safe that url() defaults to making absolute urls that will work in both clean urls ON and OFF.
It also sounds like you might have a local network problem.
-Matt
On 04/07/2008, at 2:21 PM, Pierre Rineau wrote:
Hi
I have some problèmes with the CCK image field module. This is not because of the module, but because of the core file_create_url() function.
I explain:
<?php function file_create_url($path) { // Strip file_directory_path from $path. We only include relative paths in urls. if (strpos($path, file_directory_path() . '/') === 0) { $path = trim(substr($path, strlen(file_directory_path())), '\\/'); } switch (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC)) { case FILE_DOWNLOADS_PUBLIC: return $GLOBALS['base_url'] .'/'. file_directory_path() .'/'. str_replace('\\', '/', $path); case FILE_DOWNLOADS_PRIVATE: return url('system/files/'. $path, NULL, NULL, TRUE); } } ?>
This give me an asbolute URL because of the use of $GLOBALS['url'].
If we look at the url() function, we have a boolean parameter $absolute, which is default setted to FALSE. If false is selected, , the method use base_path() as base for the url, else it uses the global $base_url.
Is this normal that drupal devs made the choice of always put absolute URL for files ? Is this a bug ? If not, why ?
The problem for me is that I use drupals behind proxies (they are in a company LAN, using internal DNS which are not accessible from outside). When giving absolute pathes, the site give me, through the proxy an internal DNS which does not work.
-- [ Drupal support list | http://lists.drupal.org/ ]