From c67ce5fe6f66ca395555da4e690e1bd3e24d394d Mon Sep 17 00:00:00 2001 From: wangchunsheng Date: Wed, 7 Sep 2011 06:46:27 +0000 Subject: [PATCH] * when upload failed, return error message. --- module/file/control.php | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/module/file/control.php b/module/file/control.php index c68cca602c..c66712e232 100644 --- a/module/file/control.php +++ b/module/file/control.php @@ -48,15 +48,22 @@ class file extends control $file = $file[0]; if($file) { - move_uploaded_file($file['tmpname'], $this->file->savePath . $file['pathname']); - $url = $this->file->webPath . $file['pathname']; + if(@move_uploaded_file($file['tmpname'], $this->file->savePath . $file['pathname'])) + { + $url = $this->file->webPath . $file['pathname']; - $file['addedBy'] = $this->app->user->account; - $file['addedDate'] = helper::today(); - unset($file['tmpname']); - $this->dao->insert(TABLE_FILE)->data($file)->exec(); + $file['addedBy'] = $this->app->user->account; + $file['addedDate'] = helper::today(); + unset($file['tmpname']); + $this->dao->insert(TABLE_FILE)->data($file)->exec(); - die(json_encode(array('error' => 0, 'url' => $url))); + die(json_encode(array('error' => 0, 'url' => $url))); + } + else + { + $error = strip_tags(sprintf($this->lang->file->errorCanNotWrite, $this->file->savePath, $this->file->savePath)); + die(json_encode(array('error' => 1, 'message' => $error))); + } } }