$object->openattachment

Name

$object->openattachment -- Open a filehandle to an attachment

Synopsis

filehandle $object->openattachment(string name, string [mode]);

Description

Minimum version: Midgard 1.4 (Bifrost)

Opens a filehandle to the attachment.

mode may be any of the following:

The optional parameter mode will default to "w" if omitted. Returned value is a file pointer which can be used with the usual PHP file functions. Use fclose() on the filehandle when done.

Returns a filehandle if successfull. Returns false on failure.

Method available for: article, element, event, event_member, group, host, member, page, pageelement, pagelink, person, preference, sitegroup, snippet, snippetdir, style and topic records.

Example

<?php
  $person = mgd_get_person(123); # person with id 123 must exist.
  $fh     = $person->openattachment("curriculum","w"); # and the attachment too.
  fputs($fh, "My curriculum");
  fclose($fh);
?>