Skip to content

Commit e1b4f76

Browse files
authored
Merge pull request #5709 from kenjis/fix-docs-incomingrequest.rst
docs: fix incorrect description about Uploaded Files in incomingrequest.rst
2 parents eb09acd + 5010f64 commit e1b4f76

File tree

2 files changed

+5
-16
lines changed

2 files changed

+5
-16
lines changed

user_guide_src/source/incoming/incomingrequest.rst

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -285,27 +285,14 @@ functions use, so this is a helpful way to "spoof" an incoming request for testi
285285
Uploaded Files
286286
--------------
287287

288-
Information about all uploaded files can be retrieved through ``$request->getFiles()``, which returns a
289-
:doc:`FileCollection </libraries/uploaded_files>` instance. This helps to ease the pain of working with uploaded files,
288+
Information about all uploaded files can be retrieved through ``$request->getFiles()``, which returns an array of
289+
``CodeIgniter\HTTP\Files\UploadedFile`` instance. This helps to ease the pain of working with uploaded files,
290290
and uses best practices to minimize any security risks.
291291
::
292292

293293
$files = $request->getFiles();
294294

295-
// Grab the file by name given in HTML form
296-
if ($files->hasFile('userfile')) {
297-
$file = $files->getFile('userfile');
298-
299-
// Generate a new secure name
300-
$name = $file->getRandomName();
301-
302-
// Move the file to it's new home
303-
$file->move('/path/to/dir', $name);
304-
305-
echo $file->getSize('mb'); // 1.23
306-
echo $file->getExtension(); // jpg
307-
echo $file->getType(); // image/jpg
308-
}
295+
See :ref:`Working with Uploaded Files <uploaded-files-accessing-files>` for the details.
309296

310297
You can retrieve a single file uploaded on its own, based on the filename given in the HTML file input::
311298

user_guide_src/source/libraries/uploaded_files.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ You should see an upload form. Try uploading an image file (either a
166166
**jpg**, **gif**, **png**, or **webp**). If the path in your controller is correct it should
167167
work.
168168

169+
.. _uploaded-files-accessing-files:
170+
169171
***************
170172
Accessing Files
171173
***************

0 commit comments

Comments
 (0)