file_unmanaged_save_data

  1. drupal
    1. drupal7
Versionen
drupal7 file_unmanaged_save_data($data, $destination = NULL, $replace = FILE_EXISTS_RENAME)

Save a string to the specified destination without calling any hooks or making any changes to the database.

This function is identical to file_save_data() except the file will not be saved to the files table and none of the file_* hooks will be called.

see file_save_data()

Übergabeparameter

$data A string containing the contents of the file.

$destination A string containing the destination location. If no value is provided then a randomly name will be generated and the file saved in Drupal's files directory.

$replace Replace behavior when the destination file already exists:

Rückgabewert

A string with the path of the resulting file, or FALSE on error.

Verwandte Themen

▾ 10 functions call file_unmanaged_save_data()

AggregatorTestCase::getEmptyOpml in modules/aggregator/aggregator.test
Create a valid but empty OPML file.
AggregatorTestCase::getInvalidOpml in modules/aggregator/aggregator.test
Create an invalid OPML file.
AggregatorTestCase::getValidOpml in modules/aggregator/aggregator.test
Create a valid OPML file from an array of feeds.
blogapi_metaweblog_new_media_object in modules/blogapi/blogapi.module
Blogging API callback. Inserts a file into Drupal.
drupal_build_css_cache in includes/common.inc
Aggregate and optimize CSS files, putting them in the files directory.
drupal_build_js_cache in includes/common.inc
Aggregate JS files, putting them in the files directory.
FileUnmanagedSaveDataTest::testFileSaveData in modules/simpletest/tests/file.test
Test the file_unmanaged_save_data() function.
file_save_data in includes/file.inc
Save a string to the specified destination and create a database file entry.
_color_save_stylesheet in modules/color/color.module
Save the rewritten stylesheet to disk.
_locale_rebuild_js in includes/locale.inc
(Re-)Creates the JavaScript translation file for a language.

Code

includes/file.inc, line 1288

<?php
function file_unmanaged_save_data($data, $destination = NULL, $replace = FILE_EXISTS_RENAME) {
  // Write the data to a temporary file.
  $temp_name = tempnam(file_directory_temp(), 'file');
  if (file_put_contents($temp_name, $data) === FALSE) {
    drupal_set_message(t('The file could not be created.'), 'error');
    return FALSE;
  }

  // Move the file to its final destination.
  return file_unmanaged_move($temp_name, $destination, $replace);
}
?>

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