@@ -14,17 +14,20 @@ Getting a File instance
14
14
***********************
15
15
16
16
You create a new File instance by passing in the path to the file in the constructor.
17
- By default, the file does not need to exist. However, you can pass an additional argument of "true"
18
- to check that the file exists and throw ``FileNotFoundException() `` if it does not.
19
17
20
18
.. literalinclude :: files/001.php
19
+ :lines: 2-
20
+
21
+ By default, the file does not need to exist. However, you can pass an additional argument of ``true ``
22
+ to check that the file exists and throw ``FileNotFoundException() `` if it does not.
21
23
22
24
Taking Advantage of Spl
23
25
***********************
24
26
25
27
Once you have an instance, you have the full power of the SplFileInfo class at the ready, including:
26
28
27
29
.. literalinclude :: files/002.php
30
+ :lines: 2-
28
31
29
32
New Features
30
33
************
@@ -38,21 +41,24 @@ You can generate a cryptographically secure random filename, with the current ti
38
41
method. This is especially useful to rename files when moving it so that the filename is unguessable:
39
42
40
43
.. literalinclude :: files/003.php
44
+ :lines: 2-
41
45
42
46
getSize()
43
47
=========
44
48
45
- Returns the size of the uploaded file in bytes:
49
+ Returns the size of the file in bytes:
46
50
47
51
.. literalinclude :: files/004.php
52
+ :lines: 2-
48
53
49
54
getSizeByUnit()
50
55
===============
51
56
52
- Returns the size of the uploaded file default in bytes. You can pass in either 'kb' or 'mb' as the first parameter to get
57
+ Returns the size of the file default in bytes. You can pass in either `` 'kb' `` or `` 'mb' `` as the first parameter to get
53
58
the results in kilobytes or megabytes, respectively:
54
59
55
60
.. literalinclude :: files/005.php
61
+ :lines: 2-
56
62
57
63
getMimeType()
58
64
=============
@@ -61,6 +67,7 @@ Retrieve the media type (mime type) of the file. Uses methods that are considere
61
67
the type of file:
62
68
63
69
.. literalinclude :: files/006.php
70
+ :lines: 2-
64
71
65
72
guessExtension()
66
73
================
@@ -70,6 +77,7 @@ will return null. This is often a more trusted source than simply using the exte
70
77
the values in **app/Config/Mimes.php ** to determine extension:
71
78
72
79
.. literalinclude :: files/007.php
80
+ :lines: 2-
73
81
74
82
Moving Files
75
83
============
@@ -78,12 +86,15 @@ Each file can be moved to its new location with the aptly named ``move()`` metho
78
86
the file to as the first parameter:
79
87
80
88
.. literalinclude :: files/008.php
89
+ :lines: 2-
81
90
82
91
By default, the original filename was used. You can specify a new filename by passing it as the second parameter:
83
92
84
93
.. literalinclude :: files/009.php
94
+ :lines: 2-
85
95
86
- The move() method returns a new File instance that for the relocated file, so you must capture the result if the
96
+ The `` move() `` method returns a new File instance that for the relocated file, so you must capture the result if the
87
97
resulting location is needed:
88
98
89
99
.. literalinclude :: files/010.php
100
+ :lines: 2-
0 commit comments