Skip to content

Commit 1620ed8

Browse files
committed
3363-doctrine-file-upload-example-uses-dir
1 parent 0428c57 commit 1620ed8

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

cookbook/doctrine/file_uploads.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,15 @@ object, which is what's returned after a ``file`` field is submitted::
300300
Using Lifecycle Callbacks
301301
-------------------------
302302

303+
.. caution::
304+
305+
Using lifecycle callbacks is a limited technique that has some drawbacks.
306+
If you want to remove the hard coded ``__DIR__`` reference inside
307+
the ``Document::getUploadRootDir()`` method, the best way is to start
308+
using explicit :doc:`doctrine listeners </cookbook/doctrine/event_listeners_subscribers>`
309+
where you will be able to inject kernel parameters such as
310+
``kernel.root_dir`` to be able to build absolute paths.
311+
303312
Even if this implementation works, it suffers from a major flaw: What if there
304313
is a problem when the entity is persisted? The file would have already moved
305314
to its final location even though the entity's ``path`` property didn't

0 commit comments

Comments
 (0)