Skip to content

Commit 5fc03b7

Browse files
authored
Merge pull request #9065 from kenjis/docs-files.rst
docs: improve files.rst
2 parents 1192b91 + 5340d8d commit 5fc03b7

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

user_guide_src/source/libraries/files.rst

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,20 @@ Getting a File instance
1414
***********************
1515

1616
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.
1917

2018
.. 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.
2123

2224
Taking Advantage of Spl
2325
***********************
2426

2527
Once you have an instance, you have the full power of the SplFileInfo class at the ready, including:
2628

2729
.. literalinclude:: files/002.php
30+
:lines: 2-
2831

2932
New Features
3033
************
@@ -38,21 +41,24 @@ You can generate a cryptographically secure random filename, with the current ti
3841
method. This is especially useful to rename files when moving it so that the filename is unguessable:
3942

4043
.. literalinclude:: files/003.php
44+
:lines: 2-
4145

4246
getSize()
4347
=========
4448

45-
Returns the size of the uploaded file in bytes:
49+
Returns the size of the file in bytes:
4650

4751
.. literalinclude:: files/004.php
52+
:lines: 2-
4853

4954
getSizeByUnit()
5055
===============
5156

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
5358
the results in kilobytes or megabytes, respectively:
5459

5560
.. literalinclude:: files/005.php
61+
:lines: 2-
5662

5763
getMimeType()
5864
=============
@@ -61,6 +67,7 @@ Retrieve the media type (mime type) of the file. Uses methods that are considere
6167
the type of file:
6268

6369
.. literalinclude:: files/006.php
70+
:lines: 2-
6471

6572
guessExtension()
6673
================
@@ -70,6 +77,7 @@ will return null. This is often a more trusted source than simply using the exte
7077
the values in **app/Config/Mimes.php** to determine extension:
7178

7279
.. literalinclude:: files/007.php
80+
:lines: 2-
7381

7482
Moving Files
7583
============
@@ -78,12 +86,15 @@ Each file can be moved to its new location with the aptly named ``move()`` metho
7886
the file to as the first parameter:
7987

8088
.. literalinclude:: files/008.php
89+
:lines: 2-
8190

8291
By default, the original filename was used. You can specify a new filename by passing it as the second parameter:
8392

8493
.. literalinclude:: files/009.php
94+
:lines: 2-
8595

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
8797
resulting location is needed:
8898

8999
.. literalinclude:: files/010.php
100+
:lines: 2-

0 commit comments

Comments
 (0)