XpressEngine Core
1.11.2
Main Page
Related Pages
Namespaces
Classes
Files
Examples
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Pages
libs
PEAR.1.9.5
HTTP
Request2
Observer
Download.php
Go to the documentation of this file.
1
<?php
2
8
class
HTTP_Request2_Observer_Download
implements
SplObserver
9
{
10
protected
$filename
;
11
protected
$fp
;
12
13
public
function
__construct
(
$filename
)
14
{
15
$this->filename =
$filename
;
16
}
17
18
public
function
update
(SplSubject $subject)
19
{
20
$event = $subject->getLastEvent();
21
22
switch
($event[
'name'
])
23
{
24
case
'receivedHeaders'
:
25
$this->fp = @fopen($this->filename,
'wb'
);
26
if
(!$this->fp)
27
{
28
throw
new
Exception(
"Cannot open target file '{$filename}'"
);
29
}
30
break
;
31
32
case
'receivedBodyPart'
:
33
case
'receivedEncodedBodyPart'
:
34
fwrite($this->fp, $event[
'data'
]);
35
break
;
36
37
case
'receivedBody'
:
38
fclose($this->fp);
39
}
40
}
41
}
HTTP_Request2_Observer_Download
Definition:
Download.php:8
HTTP_Request2_Observer_Download\__construct
__construct($filename)
Definition:
Download.php:13
HTTP_Request2_Observer_Download\update
update(SplSubject $subject)
Definition:
Download.php:18
HTTP_Request2_Observer_Download\$filename
$filename
Definition:
Download.php:10
HTTP_Request2_Observer_Download\$fp
$fp
Definition:
Download.php:11
Generated on Tue Dec 18 2018 17:04:28 for XpressEngine Core by
1.8.5