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 535793a7b4bc4f40e9d8a67d3abee32bcfa470eb 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 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cookbook/doctrine/file_uploads.rst b/cookbook/doctrine/file_uploads.rst index bd92e11de6f..7858428adf7 100644 --- a/cookbook/doctrine/file_uploads.rst +++ b/cookbook/doctrine/file_uploads.rst @@ -322,7 +322,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 +417,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; } /**