Open Source Content Management Framework

PHP midgard_blob method get_handler

  1. Example

Get file handler of a file associated with attachment.

resource get_handler([mode]);

midgard_blob method get_handler takes one argument.

  • mode, access type, the same one as used in PHP's (fopen) function.

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('r');
    $content = fread($fh);
}

?>

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

Tagged
ragnaroek
vinland
Designed by Nemein, hosted by Kafit