PHP code example of danrossiter / binary-compound-file
1. Go to this page and download the library: Download danrossiter/binary-compound-file library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
danrossiter / binary-compound-file example snippets
use DanRossiter\BinaryCompoundFile\CompoundFile;
use DanRossiter\BinaryCompoundFile\StorageType;
// Open the compound file
$handle = fopen('document.doc', 'rb');
$cfb = new CompoundFile($handle);
// Extract a specific stream
$wordDocStream = $cfb->getDirectory('WordDocument');
$content = $cfb->getStream($wordDocStream);
// Iterate through all streams
$directories = $cfb->getDirectories();
foreach ($directories as $name => $dir) {
if ($dir->getMse() === StorageType::STREAM) {
$streamContent = $cfb->getStream($dir);
echo "Stream: $name, Size: " . strlen($streamContent) . " bytes\n";
}
}
fclose($handle);
use DanRossiter\BinaryCompoundFile\CompoundFileStream;
// Register the stream wrapper
stream_wrapper_register('cfbf', CompoundFileStream::class);
// Access streams using the cfbf:// protocol
$handle = fopen('cfbf://document.doc#WordDocument', 'rb');
$content = stream_get_contents($handle);
fclose($handle);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.