function file_save


Error message

User warning: The following module is missing from the file system: theme/theme. For information about how to fix this, see the documentation page. in _drupal_trigger_error_with_delayed_logging() (line 1156 of /var/www/html/elmsln_community/
cis7 file_save(stdClass $file)
cle7 file_save(stdClass $file)
elmsmedia7 file_save(stdClass $file)
icor7 file_save(stdClass $file)
meedjum_blog7 file_save(stdClass $file)
mooc7 file_save(stdClass $file)

Saves a file object to the database.

If the $file->fid is not set a new record will be added.


$file: A file object returned by file_load().

Return value

The updated file object.

See also



Related topics

29 calls to file_save()
devel_create_users in sites/all/modules/ulmus/devel/devel_generate/
Generate some random users.
drush_feeds_import in sites/all/modules/ulmus/feeds/
Imports a given feed_name.
FeedsEnclosure::getFile in sites/all/modules/ulmus/feeds/plugins/
Get a Drupal file object of the enclosed resource, download if necessary.
FeedsFetcherResult::getFilePath in sites/all/modules/ulmus/feeds/plugins/
Get a path to a temporary file containing the resource provided by the fetcher.
FeedsFileFetcher::sourceSave in sites/all/modules/ulmus/feeds/plugins/
Override parent::sourceSave().

... See full list

1 string reference to 'file_save'
_entity_info_add_metadata in sites/all/modules/ulmus/entity/entity.module
Adds metadata and callbacks for core entities to the entity info.


includes/, line 599
API for handling file uploads and server file management.


function file_save(stdClass $file) {
  $file->timestamp = REQUEST_TIME;
  $file->filesize = filesize($file->uri);

  // Load the stored entity, if any.
  if (!empty($file->fid) && !isset($file->original)) {
    $file->original = entity_load_unchanged('file', $file->fid);

  module_invoke_all('file_presave', $file);
  module_invoke_all('entity_presave', $file, 'file');

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

  return $file;