mgd_serve_attachment

(Midgard 1.4.2 'Bifrost')

mgd_serve_attachment -- Serve an attachment

Description

bool mgd_serve_attachment (int id)

Minimum version: Midgard 1.4 (Bifrost)

Serves the appropriate Content-Type header, any other headers that were specified with PHP's header() function, and the content of the attachment identified by id to the browser.

Note: This function has to be called before any headers or even the body of an HTTP response have been sent. In Midgard, that means mgd_serve_attachment() can only be called from <[code-compat]>, <[code-global]> and <[code-init]> elements or code being called from one of those.

Make sure to exit() your application flow right after the mgd_serve_attachment() call! Otherwise any other output will be appended to the attachment stream.

Returns TRUE on success, FALSE on failure.


<?php
  mgd_serve_attachment(13);
  exit();
?>