Commit 80091116 authored by speedprogs_de's avatar speedprogs_de

added method to send file content as download to client browser

git-svn-id: https://svn.typo3.org/TYPO3v4/Extensions/terfe/branches/ter_fe2@51660 735d13b6-9817-0410-8766-e36946ffe9aa
parent 78dd1dc0
......@@ -125,7 +125,7 @@
$visibleFileName = basename($filename);
}
// Set headers
// Send headers
header('Cache-Control: no-cache, must-revalidate');
header('Expires: Sat, 10 Jan 1970 00:00:00 GMT');
header('Content-Disposition: attachment; filename=' . (string) $visibleFileName);
......@@ -138,6 +138,33 @@
}
/**
* Transfers file content to client browser
*
* This function must be called before any HTTP headers have been sent
*
* @param string $content File content
* @param string $visibleFileName File name for downloaded file
* @return boolean FALSE if something wents wrong
*/
public static function transferFileContent($content, $fileName) {
if (empty($content) || empty($fileName)) {
return FALSE;
}
// Send headers
header('Cache-Control: no-cache, must-revalidate');
header('Expires: Sat, 10 Jan 1970 00:00:00 GMT');
header('Content-Disposition: attachment; filename=' . (string) $fileName);
header('Content-type: x-application/octet-stream');
header('Content-Transfer-Encoding: binary');
// Send file contents
echo $content;
exit;
}
/**
* Get a list of all files in a directory
*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment