Skip to content

Commit 312a951

Browse files
committed
docs: add descriptions
1 parent 28ed8c9 commit 312a951

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

user_guide_src/source/libraries/uploaded_files.rst

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,19 @@ this code and save it to your **app/Controllers** directory:
8383

8484
.. literalinclude:: uploaded_files/002.php
8585

86-
.. note:: Since the value of a file upload HTML field doesn't exist, and is stored in the ``$_FILES`` global,
87-
only :ref:`rules-for-file-uploads` can be used to validate upload file with :doc:`validation`.
88-
The rule ``required`` also can't be used, so use ``uploaded`` instead.
86+
Since the value of a file upload HTML field doesn't exist, and is stored in the
87+
``$_FILES`` global, only :ref:`rules-for-file-uploads` can be used to validate
88+
upload file with :doc:`validation`.
89+
90+
The rule ``required`` cannot be used either, so if the file is required, use
91+
the rule ``uploaded`` instead.
92+
93+
Note that an empty array (``[]``) is passed as the first argument to
94+
``$this->validateData()``. It is because the file validation rules get the data
95+
for the uploaded file directly from the Request object.
96+
97+
If the form has fields other than file upload, pass the field data as the first
98+
argument.
8999

90100
The Routes
91101
==========

user_guide_src/source/libraries/validation.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -885,6 +885,8 @@ Available Rules
885885
.. literalinclude:: validation/038.php
886886
:lines: 2-
887887

888+
.. _rules-for-general-use:
889+
888890
Rules for General Use
889891
=====================
890892

@@ -1057,6 +1059,8 @@ parameter of all file upload related rules::
10571059
'avatar' => 'uploaded[avatar]|max_size[avatar,1024]',
10581060
]);
10591061

1062+
See also :ref:`file-upload-form-tutorial`.
1063+
10601064
======================= ========== ============================================= ===================================================
10611065
Rule Parameter Description Example
10621066
======================= ========== ============================================= ===================================================

0 commit comments

Comments
 (0)