Hello,

I am tryinmg access the uploaded file from a Node.Since I ovrrerode my default node.tpl.php I am unable to see the attachment.

Now I am able to access the FileName but am unable to get the 'URL that preceeds it

For eg. I have the file path and File name

print $node->files[31]->filepath
print $node->files[31]->filename

But I do not know how I should access the URL that preceeds it

say www.somehost.com/file/some.pdf

How do I get the www.somehost.com ?

as I already have the 'file' and 'some.pdf' part in the www.somehost.com/file/some.pdf.

Thank you.

Comments

yelvington’s picture

Generally, you do not need to do that. In a Web context, the current protocol and hostname are assumed.

<a href="/some/path/to/document.pdf">

If you REALLY want the hostname, it's contained in the PHP superglobal $_SERVER['SERVER_NAME'].

davyvdb’s picture

Use <?php print file_create_url($node->files[31]->filepath) ?>

http://api.drupal.org/api/function/file_create_url/5