0

I need to get the relative path to a file, in this case, what i need is:

/sites/default/files/pics/DSC00873_39.JPG

But all I seem to be able to get is the following:

$file = file_load($pic);
print $file->uri; // public://pics/DSC00873_39.JPG 

Any ideas please?

  • I don't get it. What does the UID have to do with anything? – Chance G Feb 22 '13 at 0:22
2

Yep. There is a function for that.

http://api.drupal.org/api/drupal/includes%21file.inc/function/file_create_url/7

| improve this answer | |
  • 1
    yep, return file_create_url($file->uri); – rix Feb 23 '13 at 14:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.