Location: PHPKode > scripts > Recover Stream > recover-stream/RecoverFileStream.class.php
<?php 

require_once(dirname(__FILE__) . '/RecoverStream.class.php');

class RecoverFileStream extends RecoverStream {

	var $FileName    = '';
	var $ContentType = '';
	var $fh          = null;

	function RecoverFileStream() {
		$this->__constructor();
	} 
	
	function __constructor() {
		parent::__constructor();
	}
	
	function Open() {
		$this->fh = @fopen($this->FileName, 'r');
		if ($this->fh !== false) {
			return true;
		}
		return false;
	}
	
	function Close() {
		return fclose($this->fh);
	}

	function Seek($offset) {
		return fseek($this->fh, $offset, SEEK_SET) == 0;
	}

	function Read($length) {
		return fread($this->fh, $length);
	}
	
	function ContentType() {
		return $this->ContentType;
	}

	function ContentLength() {
		return filesize($this->FileName);
	}
	
	function AdditionalHeaders() {
		return array('Content-Disposition: attachment; filename="' . $this->FileName . '"');
	}

}

?>
Return current item: Recover Stream