0

I did some custom scripting in a custom module. After my scripting I would like to go to the file path of a file field. How can I achive this? I have the uri of the file to display it. I tried drupal_goto('$result') where $result is result of query with uri field of file.

Although drupal_goto($result) does not work. Any suggestions??

2 Answers2

1
drupal_goto(file_create_url($result));

The uri contains public://

If this doesnt work, print the result of file_create_url($result) and copy past it in your browser see if the file is really there. By the way, you should avoid querying the database just for one file and use a file_load() to avoid bad surprises.

Laurent Fauvel
  • 631
  • 6
  • 12
0

Thanks this realy helped me in the good direction...

Now I used this
$file = file_load($fid);
$uri = $file->uri;
$url = file_create_url($uri);

drupal_goto($url);

Hope this will help someone :-)