file_create_url

  1. drupal
    1. drupal6
    2. drupal7
Versionen
drupal6 – drupal7 file_create_url($path)

Create the download path to a file.

Übergabeparameter

$path A string containing the path of the file to generate URL for.

Rückgabewert

A string containing a URL that can be used to download the file.

Verwandte Themen

▾ 8 functions call file_create_url()

blogapi_metaweblog_new_media_object in modules/blogapi/blogapi.module
Blogging API callback. Inserts a file into Drupal.
FileDownloadTest::testPrivateFileTransfer in modules/simpletest/tests/file.test
Test the private file transfer system.
ImportOPMLTestCase::submitImportForm in modules/aggregator/aggregator.test
Submit form with invalid, empty and valid OPML files.
ImportOPMLTestCase::validateImportFormFields in modules/aggregator/aggregator.test
Submit form filled with invalid fields.
theme_upload_attachments in modules/upload/upload.module
Displays file attachments in table
UploadTestCase::checkUploadedFile in modules/upload/upload.test
Check that uploaded file is accessible and verify the contents against the original.
upload_node_view in modules/upload/upload.module
Implementation of hook_node_view().
_upload_form in modules/upload/upload.module

Code

includes/file.inc, line 85

<?php
function file_create_url($path) {
  // Strip file_directory_path from $path. We only include relative paths in
  // URLs.
  if (strpos($path, file_directory_path() . '/') === 0) {
    $path = trim(substr($path, strlen(file_directory_path())), '\\/');
  }
  switch (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC)) {
    case FILE_DOWNLOADS_PUBLIC:
      return $GLOBALS['base_url'] . '/' . file_directory_path() . '/' . str_replace('\\', '/', $path);
    case FILE_DOWNLOADS_PRIVATE:
      return url('system/files/' . $path, array('absolute' => TRUE));
  }
}
?>

Kommentare

Kommentar hinzufügen

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Zulässige HTML-Tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Zeilen und Absätze werden automatisch erzeugt.

Weitere Informationen über Formatierungsoptionen

Kommentar hinzufügen

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Zulässige HTML-Tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Zeilen und Absätze werden automatisch erzeugt.

Weitere Informationen über Formatierungsoptionen