Drupal: Primary link item to a relative file on the server
I want to create a link in my Primary Links menu to link to a file on my serve开发者_StackOverflow中文版r, not a drupal node. If I try to set the path to files/whatever.pdf
or ./files/whatever.pdf
or some variation thereof, Drupal says: The path 'files/whatever.pdf' is either invalid or you do not have access to it.
I know I can link with an absolute url like http://mydomain.com/files/whatever.pdf
but it seems silly to use an absolute link for what should be a local file that I can link to relatively.
Is there a way to do what I want?
Drupal's menu system validates relative links to make sure they're valid Drupal page URLs. Unfortunately, this means you can't link to files without an absolute path.
You could use webfilemanager and uploading the file to webfm. You then access the file by using /webfm_send/10 where 10 is the number of the file within webfm.
http://drupal.org/project/webfm
You can link to a local file if you have the "Download method" set to "Private" in admin/settings/file-system and use the system path for the file (or its URL alias). This would make the entire file system use Drupal as the download method (instead of your web server, which would be faster). URLs to the files as they were when the download method was public would remain the same. This would assume that you've uploaded the file somehow using the Upload module, either as an attachment to a node or through a FileField (or similar module).
精彩评论