Documentation

Server

Download (pdf)

Overview

Hubzero\Content\Server object serve up files as download.

This allows for simple but smart objects with get and set methods and an internal error handler

Usage

Set the filename
filename(string filename = null) : mixed

Return: String filename if field is set, NULL if not

 

Set the disposition value
disposition(string $disposition = null) : mixed

Return: String value of disposition if field is set, NULL if not

$disposition:

  • 'inline': Read the contents of a file and display it inline (display in browser window)
  • 'attachment': Read the contents of a file and display as attachment (browser should default to saving file rather than displaying)

 

Set the name to save file as
saveas(string $saveas = null) : mixed

Return: String name of the file if field is set, NULL if not

$saveas: name to save file as

 

Read the contents of a file and display it
serve() : boolean

Example

$server = new Hubzero\Content\Server;
$server->filename(PATH_APP . '/site/media/patch.txt');
$server->disposition('attachment');
$server->saveas('bugfix.patch');
$server->serve();

Last modified: