I use drupal_realpath() to do includes for some code samples I have:


This gives the real path C:\www\sites\mysite\files\php_includes\functions.php.
What is the command to get the HTTP path http://mysite.com/sites/files/php_includes/functions.php?

The api documentation says "RealPath is deprecated"... if it's deprecated, what is supposed to replace it to get the same path (either C:\... or http://...)?

1 Answer 1


To get the HTTP path of a file, you need to use file_create_url($uri).


This will output http://mysite.com/sites/files/php_includes/functions.php.

Regarding the fact that drupal_realpath() is deprecated, I think it's to warn developers to avoid relying on file system path and instead use wrappers.

  • Does it works well with S3FS module? Apr 6, 2019 at 5:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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