From 8237344c811891d4f82f1ea1f6ab2f56dd7ed213 Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 31 Jan 2023 13:46:37 +0900 Subject: [PATCH 1/3] docs: add section titles --- .../source/libraries/uploaded_files.rst | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/user_guide_src/source/libraries/uploaded_files.rst b/user_guide_src/source/libraries/uploaded_files.rst index 837052c59d21..3de0653d8c19 100644 --- a/user_guide_src/source/libraries/uploaded_files.rst +++ b/user_guide_src/source/libraries/uploaded_files.rst @@ -307,20 +307,34 @@ version, use ``getMimeType()`` instead: Moving Files ============ +with Original Filename +---------------------- + Each file can be moved to its new location with the aptly named ``move()`` method. This takes the directory to move the file to as the first parameter: .. literalinclude:: uploaded_files/016.php -By default, the original filename was used. You can specify a new filename by passing it as the second parameter: +By default, the original filename was used. + +with New Filename +----------------- + +You can specify a new filename by passing it as the second parameter: .. literalinclude:: uploaded_files/017.php +Check if the File Moved +----------------------- + Once the file has been removed the temporary file is deleted. You can check if a file has been moved already with the ``hasMoved()`` method, which returns a boolean: .. literalinclude:: uploaded_files/018.php +When Moving Fails +----------------- + Moving an uploaded file can fail, with an HTTPException, under several circumstances: - the file has already been moved From 639ac1e9c0862e3709ae4eb0a0a1dfae8743999d Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 31 Jan 2023 13:47:09 +0900 Subject: [PATCH 2/3] docs: add "Overwriting Existing File" --- user_guide_src/source/libraries/uploaded_files.rst | 12 ++++++++++++ .../source/libraries/uploaded_files/022.php | 3 +++ 2 files changed, 15 insertions(+) create mode 100644 user_guide_src/source/libraries/uploaded_files/022.php diff --git a/user_guide_src/source/libraries/uploaded_files.rst b/user_guide_src/source/libraries/uploaded_files.rst index 3de0653d8c19..9e6d68f92f07 100644 --- a/user_guide_src/source/libraries/uploaded_files.rst +++ b/user_guide_src/source/libraries/uploaded_files.rst @@ -324,6 +324,18 @@ You can specify a new filename by passing it as the second parameter: .. literalinclude:: uploaded_files/017.php +By default, if the destination file already exists, a new filename will be used. +For example, if **image_name.jpg** already exists in the directory, then the +filename will be **image_name_1.jpg**. + +Overwriting Existing File +------------------------- + +You can overwrite the existing file by passing ``true`` +as the third parameter: + +.. literalinclude:: uploaded_files/022.php + Check if the File Moved ----------------------- diff --git a/user_guide_src/source/libraries/uploaded_files/022.php b/user_guide_src/source/libraries/uploaded_files/022.php new file mode 100644 index 000000000000..e834acba3d23 --- /dev/null +++ b/user_guide_src/source/libraries/uploaded_files/022.php @@ -0,0 +1,3 @@ +move(WRITEPATH . 'uploads', null, true); From eeb04898ba4f48634051147ab9323b4c4a8a8350 Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 31 Jan 2023 16:58:46 +0900 Subject: [PATCH 3/3] docs: move paragraph --- user_guide_src/source/libraries/uploaded_files.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/user_guide_src/source/libraries/uploaded_files.rst b/user_guide_src/source/libraries/uploaded_files.rst index 9e6d68f92f07..b91b34ecd718 100644 --- a/user_guide_src/source/libraries/uploaded_files.rst +++ b/user_guide_src/source/libraries/uploaded_files.rst @@ -324,13 +324,13 @@ You can specify a new filename by passing it as the second parameter: .. literalinclude:: uploaded_files/017.php -By default, if the destination file already exists, a new filename will be used. -For example, if **image_name.jpg** already exists in the directory, then the -filename will be **image_name_1.jpg**. - Overwriting Existing File ------------------------- +By default, if the destination file already exists, a new filename will be used. +For example, if **image_name.jpg** already exists in the directory, then the +filename will be **image_name_1.jpg** automatically. + You can overwrite the existing file by passing ``true`` as the third parameter: