Skip to content

Commit

Permalink
docs: add descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjis committed May 9, 2024
1 parent 28ed8c9 commit 312a951
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
16 changes: 13 additions & 3 deletions user_guide_src/source/libraries/uploaded_files.rst
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,19 @@ this code and save it to your **app/Controllers** directory:

.. literalinclude:: uploaded_files/002.php

.. note:: Since the value of a file upload HTML field doesn't exist, and is stored in the ``$_FILES`` global,
only :ref:`rules-for-file-uploads` can be used to validate upload file with :doc:`validation`.
The rule ``required`` also can't be used, so use ``uploaded`` instead.
Since the value of a file upload HTML field doesn't exist, and is stored in the
``$_FILES`` global, only :ref:`rules-for-file-uploads` can be used to validate
upload file with :doc:`validation`.

The rule ``required`` cannot be used either, so if the file is required, use
the rule ``uploaded`` instead.

Note that an empty array (``[]``) is passed as the first argument to
``$this->validateData()``. It is because the file validation rules get the data
for the uploaded file directly from the Request object.

If the form has fields other than file upload, pass the field data as the first
argument.

The Routes
==========
Expand Down
4 changes: 4 additions & 0 deletions user_guide_src/source/libraries/validation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -885,6 +885,8 @@ Available Rules
.. literalinclude:: validation/038.php
:lines: 2-

.. _rules-for-general-use:

Rules for General Use
=====================

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

See also :ref:`file-upload-form-tutorial`.

======================= ========== ============================================= ===================================================
Rule Parameter Description Example
======================= ========== ============================================= ===================================================
Expand Down

0 comments on commit 312a951

Please sign in to comment.