Quick links: Content - sections - sub sections

To send binary content to the user (a graphic, a video, some sound, an archive, etc.), jResponseBinary should be used. To use it, set 'binary' as the type of response used.

$resp = $this->getResponse('binary');

Afterwards, some variables need to be set to a correct value before content is displayed.

First, you have to set outputFileName property. outputFileName will be the name shown to the user.

 $resp->outputFileName = 'filename.gif';

Next, you can define the mime type of your content:

 $resp->mimeType = 'image/gif';

You have an option for files you want the user to download (particularly, files not rendered by common browsers - archives, for example). To force the download of the file, simple set doDownload to true.

 $resp->doDownload = true;

For the content itself, you have to define either filename or content property.

If it is an existing file, just use filename:

   $resp->fileName = jApp::varPath('file_to_send.gif');

Otherwise, if your content is generated or comes from your database, use content:

   $resp->content = '...';