mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-24 10:22:18 +00:00
- core/FHC_Controller->outputFile cleaned
- Adapted controllers/lehre/anrechnung/* to make use of the changed core/FHC_Controller->outputFile - Changed application/core/FS_Model: - It's not abstract anymore - Added new constants READ_MODE, READ_WRITE_MODE, READ_APPEND_MODE, BLOCK_SIZE, META_URI - Constructor accept a mandatory parameter - Does not load the FilesystemLib anymore - Renamed all the public methods with the suffix Base64 - Added new public methods openRead, openReadWrite, openReadAppend, close, readBlock and write - Added new private methods _checkPath and _open - Removed the libraries/FilesystemLib - Adapted model content/DmsFS_model to make use of the changed core/FS_Model - Changed libraries/DmsLib: - Does not extend the FHC_Controller anymore - removed private propery UPLOAD_PATH - Cleaned code, make use of the standards - Adapted to use the Base64 suffixed methods from core/FS_Model - Deprecated old methods - Refactored public methods download and getFileInfo
This commit is contained in:
@@ -132,31 +132,41 @@ abstract class FHC_Controller extends CI_Controller
|
||||
{
|
||||
$this->output->set_content_type('application/json')->set_output(json_encode($mixed));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* To download the given file represented by the fileObj parameter.
|
||||
* fileObj has the following structure:
|
||||
* $fileObj->filename
|
||||
* $fileObj->file
|
||||
* $fileObj->name
|
||||
* $fileObj->mimetype
|
||||
* $fileObj->disposition
|
||||
*/
|
||||
protected function outputFile($fileObj)
|
||||
{
|
||||
if (file_exists($fileObj->file))
|
||||
// If the file exists
|
||||
if (isset($fileObj->file) && !isEmptyString($fileObj->file) && file_exists($fileObj->file))
|
||||
{
|
||||
$finfo = new finfo(FILEINFO_MIME);
|
||||
|
||||
header('Content-Description: File Transfer');
|
||||
header('Content-Type: '. $finfo->file($fileObj->file));
|
||||
header('Content-Type: '. $fileObj->mimetype);
|
||||
header('Expires: 0');
|
||||
header('Cache-Control: must-revalidate');
|
||||
header('Pragma: public');
|
||||
header('Content-Length: ' . filesize($fileObj->file));
|
||||
|
||||
if (isset($fileObj->disposition) && ($fileObj->disposition == 'inline' || $fileObj->disposition == 'attachment'))
|
||||
|
||||
if (isset($fileObj->disposition)
|
||||
&& ($fileObj->disposition == 'inline' || $fileObj->disposition == 'attachment'))
|
||||
{
|
||||
header('Content-Disposition: '. $fileObj->disposition. '; filename="'. $fileObj->name. '"');
|
||||
}
|
||||
|
||||
readfile($fileObj->file);
|
||||
|
||||
exit;
|
||||
|
||||
readfile($fileObj->file); // reads the file content to the output buffer
|
||||
}
|
||||
else
|
||||
{
|
||||
// Otherwise print an error
|
||||
show_error('The provided file does not exist: '.(isset($fileObj->file) ? $fileObj->file : 'file not given'));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user