diff --git a/cookbook/doctrine/file_uploads.rst b/cookbook/doctrine/file_uploads.rst index ac95c439bb4..16816db6a4c 100644 --- a/cookbook/doctrine/file_uploads.rst +++ b/cookbook/doctrine/file_uploads.rst @@ -120,9 +120,10 @@ look like this:: Next, create this property on your ``Document`` class and add some validation rules:: -use Symfony\Component\HttpFoundation\File\UploadedFile; + use Symfony\Component\HttpFoundation\File\UploadedFile; // ... + class Document { /** @@ -322,7 +323,7 @@ object, which is what's returned after a ``file`` field is submitted:: $this->path = $this->getFile()->getClientOriginalName(); // clean up the file property as you won't need it anymore - $this->setFile(null); + $this->file = null; } Using Lifecycle Callbacks @@ -408,7 +409,7 @@ Next, refactor the ``Document`` class to take advantage of these callbacks:: // the entity from being persisted to the database on error $this->getFile()->move($this->getUploadRootDir(), $this->path); - $this->setFile(null); + // check if we have an old image if (isset($this->temp)) { @@ -417,6 +418,7 @@ Next, refactor the ``Document`` class to take advantage of these callbacks:: // clear the temp image path $this->temp = null; } + $this->file = null; } /**