You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
.. note:: The files here correspond to ``$_FILES``. Even if a user just clicks submit button of a form and does not upload any file, the file will still exist. You can check that the file was actually uploaded by the ``isValid()`` method in UploadedFile. See :ref:`verify-a-file` for more details.
Copy file name to clipboardExpand all lines: user_guide_src/source/libraries/uploaded_files.rst
+12-6Lines changed: 12 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -194,6 +194,8 @@ Which would return a simple array like::
194
194
'avatar' => // UploadedFile instance
195
195
]
196
196
197
+
.. note:: The UploadedFile instance corresponds to ``$_FILES``. Even if a user just clicks the submit button and does not upload any file, the instance will still exist. You can check that the file was actually uploaded by the ``isValid()`` method in UploadedFile. See :ref:`verify-a-file`.
198
+
197
199
If you used an array notation for the name, the input would look something like::
If you just need to access a single file, you can use ``getFile()`` to retrieve the file instance directly. This will return an instance of ``CodeIgniter\HTTP\Files\UploadedFile``:
232
234
233
235
Simplest usage
234
-
^^^^^^^^^^^^^^
236
+
--------------
235
237
236
238
With the simplest usage, a single file might be submitted like::
237
239
@@ -242,7 +244,7 @@ Which would return a simple file instance like::
242
244
$file = $this->request->getFile('userfile');
243
245
244
246
Array notation
245
-
^^^^^^^^^^^^^^
247
+
--------------
246
248
247
249
If you used an array notation for the name, the input would look something like::
0 commit comments