From eb60e99d5cf6c611d151e78fb1b63b6f8a4f4a31 Mon Sep 17 00:00:00 2001 From: Loic d'Anterroches Date: Thu, 27 Nov 2008 09:48:01 +0100 Subject: [PATCH] Fixed to have correct post failure cleaning of the uploaded file. Note: Latest Pluf release needed. --- src/IDF/Form/Upload.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/IDF/Form/Upload.php b/src/IDF/Form/Upload.php index f308142..91807fd 100644 --- a/src/IDF/Form/Upload.php +++ b/src/IDF/Form/Upload.php @@ -109,6 +109,18 @@ class IDF_Form_Upload extends Pluf_Form return $this->cleaned_data; } + /** + * If we have uploaded a file, but the form failed remove it. + * + */ + function failed() + { + if (!empty($this->cleaned_data['file']) + and file_exists(Pluf::f('upload_path').'/'.$this->project->shortname.'/files/'.$this->cleaned_data['file'])) { + @unlink(Pluf::f('upload_path').'/'.$this->project->shortname.'/files/'.$this->cleaned_data['file']); + } + } + /** * Save the model in the database. *