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/api.elmsln.org/includes/bootstrap.inc).
cis7 file.inc file_save(stdClass $file)
cle7 file.inc file_save(stdClass $file)
elmsmedia7 file.inc file_save(stdClass $file)
icor7 file.inc file_save(stdClass $file)
meedjum_blog7 file.inc file_save(stdClass $file)
mooc7 file.inc file_save(stdClass $file)

Saves a file object to the database.

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

Parameters

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

Return value

The updated file object.

See also

hook_file_insert()

hook_file_update()

Related topics

29 calls to file_save()
devel_create_users in sites/all/modules/ulmus/devel/devel_generate/devel_generate.inc
Generate some random users.
drush_feeds_import in sites/all/modules/ulmus/feeds/feeds.drush.inc
Imports a given feed_name.
FeedsEnclosure::getFile in sites/all/modules/ulmus/feeds/plugins/FeedsParser.inc
Get a Drupal file object of the enclosed resource, download if necessary.
FeedsFetcherResult::getFilePath in sites/all/modules/ulmus/feeds/plugins/FeedsFetcher.inc
Get a path to a temporary file containing the resource provided by the fetcher.
FeedsFileFetcher::sourceSave in sites/all/modules/ulmus/feeds/plugins/FeedsFileFetcher.inc
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.

File

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

Code

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');
  }

  unset($file->original);
  return $file;
}
Error | ELMSLN API

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/api.elmsln.org/includes/common.inc:2791) in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/api.elmsln.org/sites/all/modules/apc/drupal_apc_cache.inc).
The website encountered an unexpected error. Please try again later.