$object->openattachment

(unknown)

$object->openattachment -- Open a record attachment as a file handle

Description

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

Minimum version: Midgard 1.4 (Bifrost)

Opens the attachment for writing. This will delete existing content unless you use the second (optional) parameter to specify the open mode; see the mode parameters for fopen(), the default is "w". The return value is a file pointer which can be used with the usual PHP file functions. Use fclose() on the filehandle when you are done.

Returns a filehandle if successful. Returns FALSE on failure.


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

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