function content_files_handle_download

7.x content.module content_files_handle_download($fid)
6.x content.module content_files_handle_download($fid)

This actually finds and downloads the file for the user, decrypting if necessary.

File

modules/content/content.module, line 264

Code

function content_files_handle_download($fid) {


  $file = content_get_uploaded_file($fid);

  if (!$file) {
    display_not_found();
    die;
  }

  // Otherwise, now we proceed.
  $file_contents = @file_get_contents($file ["full_filename"]);

  if ($file_contents && intval($file ["is_encrypted"]) === 1 && function_exists("encryption_decrypt")) {
    $file_contents = encryption_decrypt($file_contents);
  }

  // Okay, now let's spit it out to the browser for download.
  if (isset($file ['filetype'])) {
    header('Content-type: ' . $file ["filetype"]);
  }
  header('Content-Disposition: attachment; filename="' . $file ["original_filename"] . '"');
  print $file_contents;

  die;

}