From d192f880d4f16769a94cf736d0b94c4f51ceca95 Mon Sep 17 00:00:00 2001 From: Alexandre Daubois Date: Mon, 4 Dec 2023 09:06:49 +0100 Subject: [PATCH] [HttpFoundation] Add `UploadedFile::getClientOriginalPath()` --- controller/upload_file.rst | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/controller/upload_file.rst b/controller/upload_file.rst index c05e78997ba..e5f260379b3 100644 --- a/controller/upload_file.rst +++ b/controller/upload_file.rst @@ -194,13 +194,19 @@ There are some important things to consider in the code of the above controller: users. This also applies to the files uploaded by your visitors. The ``UploadedFile`` class provides methods to get the original file extension (:method:`Symfony\\Component\\HttpFoundation\\File\\UploadedFile::getClientOriginalExtension`), - the original file size (:method:`Symfony\\Component\\HttpFoundation\\File\\UploadedFile::getSize`) + the original file size (:method:`Symfony\\Component\\HttpFoundation\\File\\UploadedFile::getSize`), + the client original path (:method:`Symfony\\Component\\HttpFoundation\\File\\UploadedFile::getClientOriginalPath`) and the original file name (:method:`Symfony\\Component\\HttpFoundation\\File\\UploadedFile::getClientOriginalName`). However, they are considered *not safe* because a malicious user could tamper that information. That's why it's always better to generate a unique name and use the :method:`Symfony\\Component\\HttpFoundation\\File\\UploadedFile::guessExtension` method to let Symfony guess the right extension according to the file MIME type; +.. versionadded:: 7.1 + + The :method:`Symfony\\Component\\HttpFoundation\\File\\UploadedFile::getClientOriginalPath` + method was introduced in Symfony 7.1. + You can use the following code to link to the PDF brochure of a product: .. code-block:: html+twig