From 595d6ef6534791a0d418a1ae5ea3f45a41b85849 Mon Sep 17 00:00:00 2001 From: Andrea Giuliano Date: Tue, 2 Apr 2013 23:21:34 +0200 Subject: [PATCH 1/2] Fix upload code --- cookbook/doctrine/file_uploads.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cookbook/doctrine/file_uploads.rst b/cookbook/doctrine/file_uploads.rst index ac95c439bb4..bd92e11de6f 100644 --- a/cookbook/doctrine/file_uploads.rst +++ b/cookbook/doctrine/file_uploads.rst @@ -408,7 +408,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 +417,7 @@ Next, refactor the ``Document`` class to take advantage of these callbacks:: // clear the temp image path $this->temp = null; } + $this->setFile(null); } /** From bac7612adbb7523f3a3e27d0e5c1a6f23bd4e9b2 Mon Sep 17 00:00:00 2001 From: Andrea Giuliano Date: Wed, 3 Apr 2013 00:20:41 +0200 Subject: [PATCH 2/2] Fix file error --- cookbook/doctrine/file_uploads.rst | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cookbook/doctrine/file_uploads.rst b/cookbook/doctrine/file_uploads.rst index bd92e11de6f..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 @@ -417,7 +418,7 @@ Next, refactor the ``Document`` class to take advantage of these callbacks:: // clear the temp image path $this->temp = null; } - $this->setFile(null); + $this->file = null; } /**