Definition

file_set_status($file, $status = FILE_STATUS_PERMANENT)
drupal-cvs/includes/file.inc, line 879

Description

Set the status of a file.

Parameters

$file A Drupal file object.

$status A status value to set the file to.

  • FILE_STATUS_TEMPORARY - A temporary file that Drupal's garbage collection will remove.
  • FILE_STATUS_PERMANENT - A permanent file that Drupal's garbage collection will not remove.

Return value

File object if the change is successful, or FALSE in the event of an error.

Related topics

Namesort iconDescription
File interfaceCommon file handling functions.

Code

<?php
function file_set_status($file, $status = FILE_STATUS_PERMANENT) {
  if (db_query('UPDATE {files} SET status = %d WHERE fid = %d', array($status, $file->fid))) {
    $file->status = $status;
    return TRUE;
  }
  return FALSE;
}
?>