You are here

function demo_download in Demonstration site (Sandbox / Snapshot) 7

Same name and namespace in other branches
  1. 5 demo.admin.inc \demo_download()
  2. 6 demo.admin.inc \demo_download()

Transfer (download) a snapshot file.

@todo Allow to download an bundled archive of snapshot files.

Parameters

$filename: The snapshot filename to transfer.

$type: The file type, i.e. extension to transfer.

1 string reference to 'demo_download'
demo_menu in ./demo.module
Implements hook_menu().

File

./demo.admin.inc, line 695
Demonstration Site administrative pages.

Code

function demo_download($filename, $type) {
  $fileconfig = demo_get_fileconfig($filename);
  if (!isset($fileconfig[$type . 'file']) || !file_exists($fileconfig[$type . 'file'])) {
    return MENU_NOT_FOUND;
  }

  // Force the client to re-download and trigger a file save download.
  $headers = array(
    'Cache-Control: private',
    'Content-Type: application/octet-stream',
    'Content-Length: ' . filesize($fileconfig[$type . 'file']),
    'Content-Disposition: attachment, filename=' . $fileconfig[$type],
  );
  file_transfer($fileconfig[$type . 'file'], $headers);
}