Open Source Content Management System

PHP midgard_blob method get_handler

  1. Example

Get file handler of a file associated with attachment.

resource get_handler(void);

midgard_blob method get_handler takes no parameters.

Get file handler ( a stream ) from a file. NULL is explicitly returned if file handler can not be created.

Read about read_content method if you want to read content from small files.

Example

<?php

try {
    $attachment = new midgard_attachment($guid);
} catch (midgard_error_exception $e) {
    echo $e->getMessage();
}

try {
    $blob = new midgard_blob($attachment);
} catch (midgard_error_exception $e) {
    echo $e->getMessage();
}

if($blob->exists()) {
    $fh = $blob->get_handler();
    $content = fread($fh);
}

?>

More details about fails can be found in [midgard-core docs][0].

Designed by Nemein, hosted by Anykey