File tree Expand file tree Collapse file tree
user_guide_src/source/libraries Expand file tree Collapse file tree Original file line number Diff line number Diff 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
90100The Routes
91101==========
Original file line number Diff line number Diff line change @@ -885,6 +885,8 @@ Available Rules
885885.. literalinclude :: validation/038.php
886886 :lines: 2-
887887
888+ .. _rules-for-general-use :
889+
888890Rules 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======================= ========== ============================================= ===================================================
10611065Rule Parameter Description Example
10621066======================= ========== ============================================= ===================================================
You can’t perform that action at this time.
0 commit comments