You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Returns a parsed file object for use when fetching the remote file
32
29
```php
33
-
<?php
34
30
/*...*/
35
-
$file = $p->find(); # Returns the cat.png file object (as set on init)
36
-
# or
37
-
$file = $p->find('cat2.png'); # Search and return other file objects
38
-
39
-
# You can call methods here to fetch ZIP header information too
40
-
# The full list of file header properties can be found in CDFile.php
41
-
$size = $file->size(); # size in bytes
42
-
$fullName = $file->name(); # full file name in zip, including path
31
+
32
+
# Search and return other file objects
33
+
if($file = $p->find('cat2.png')) {
34
+
# You can call methods here to fetch ZIP header information too
35
+
# The full list of file header properties can be found in CDFile.php
36
+
$size = $file->size(); # size in bytes
37
+
$fullName = $file->name(); # full file name in zip, including path
38
+
}
39
+
43
40
```
44
41
45
-
###### get($file, $output = false):
42
+
###### get($file):
46
43
Returns, or outputs the file fetched from the remote ZIP.
47
44
48
-
**Note**: You should ensure no content is outputted before running```->get($file, true)``` as this will cause the file download to contain invalid data.
49
-
*Hint*: put ```ob_start()``` at the start of your script, then run ```ob_clean()``` before calling get.
45
+
**Note**: You should ensure no content is outputted before echo-ing```->get()``` as this will cause the file download to contain invalid data.
46
+
*Hint*: put ```ob_start()``` at the start of your script, then run ```ob_clean()``` before output.
50
47
```php
51
-
<?php
52
48
/*...*/
53
-
if($file) {
54
-
$data = $p->get($file); # Return
55
-
# or
56
-
$p->get($file, true); # Output (download)
49
+
50
+
if($file = $p->find('cat3.png')) {
51
+
$fileData = $p->get($file);
57
52
}
58
53
```
59
54
@@ -68,13 +63,17 @@ use Stnvh\Partial\Zip as Partial;
68
63
69
64
ob_start(); # will capture all output
70
65
71
-
$p = new Partial('http://some.site.com/cats.zip', 'cat.png');
66
+
$p = new Partial('http://some.site.com/cats.zip');
72
67
73
68
# Get file object
74
-
$file = $p->find();
75
-
if($file) {
76
-
ob_clean(); # removes everything from current output to ensure file downloads correctly
77
-
# Output to browser:
78
-
$p->get($file, true);
69
+
if($file = $p->find('cat.png')) {
70
+
# removes everything from current output to ensure file downloads correctly
0 commit comments