This comes handy when a file should be sent to the user as a download instead of saving it into the filesystem.
Usage:
$this->modx->getService('file','modFileHandler');
// create the file object and do something with it
$fileobj = $this->modx->file->make($this->modx->getOption('assets_path') . 'filename.ext');
if ( !$fileobj->setContent($data) ) {
$this->modx->log(modX::LOG_LEVEL_ERROR, '[modFileHandler] file could not be written at ' . $fileobj->getPath());
} else {
$this->modx->log(modX::LOG_LEVEL_ERROR, '[modFileHandler] written at ' . $fileobj->getPath());
}
return $fileobj->makeDownload();
exside created Redmine issue ID 10277
This comes handy when a file should be sent to the user as a download instead of saving it into the filesystem.
Usage: