file_save

  1. drupal
    1. drupal7
Versionen
drupal7 file_save($file)

Save a file object to the database.

If the $file->fid is not set a new record will be added. Re-saving an existing file will not change its status.

see hook_file_insert()

Übergabeparameter

$file A file object returned by file_load().

Rückgabewert

The updated file object.

See also

hook_file_update()

Verwandte Themen

▾ 10 functions call file_save()

FileLoadTest::testMultiple in modules/simpletest/tests/file.test
This will test loading file data from the database.
FileLoadTest::testSingleValues in modules/simpletest/tests/file.test
Load a single file and ensure that the correct values are returned.
FileSaveTest::testFileSave in modules/simpletest/tests/file.test
file_copy in includes/file.inc
Copy a file to a new location and adds a file record to the database.
file_move in includes/file.inc
Move a file to a new location and update the file's database entry.
file_save_data in includes/file.inc
Save a string to the specified destination and create a database file entry.
file_save_upload in includes/file.inc
Saves a file upload to a new location.
upload_save in modules/upload/upload.module
user_save in modules/user/user.module
Save changes to a user account or add a new user.
user_update_7004 in modules/user/user.install
Add the user's pictures to the {files} table and make them managed files.

Code

includes/file.inc, line 331

<?php
function file_save($file) {
  $file = (object) $file;
  $file->timestamp = REQUEST_TIME;
  $file->filesize = filesize($file->filepath);

  if (empty($file->fid)) {
    drupal_write_record('files', $file);
    // Inform modules about the newly added file.
    module_invoke_all('file_insert', $file);
  }
  else {
    drupal_write_record('files', $file, 'fid');
    // Inform modules that the file has been updated.
    module_invoke_all('file_update', $file);
  }

  return $file;
}
?>

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