How to convert a schema: //filename.pdf to a relative path in Drupal 7?

Is there a function in Drupal 7 to convert "public: //filename.pdf" to "/path_to_public_directory/filename.pdf"? I found a function that connected the path of the circuit, but cannot find one that does the opposite.

+4
source share
3 answers

You can use file_create_url() to do just that:

 $uri = 'public://filename.pdf'; $path = file_create_url($uri); 
+3
source

Use conf_path () to find the path to the file directory.

 <?php $drupal_files = conf_path() . "/files"; print "The Files Directory: " . $drupal_files; ?> 

http://api.drupal.org/api/drupal/includes--bootstrap.inc/function/conf_path

0
source

drupal_realpath ($ URI) Allows an absolute path to a local URI file or file path. https://api.drupal.org/api/drupal/includes!file.inc/function/drupal_realpath/7

0
source

Source: https://habr.com/ru/post/1383104/


All Articles