From ceb07822339d92e399b3c93069ff356fcc68a278 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Mon, 10 Nov 2008 12:28:58 +0000 Subject: Add support for multi-file-upload using jquery.MultiFile and modify Item_Controller to accept it. --- core/controllers/item.php | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) (limited to 'core/controllers') diff --git a/core/controllers/item.php b/core/controllers/item.php index 38049380..d2986cc7 100644 --- a/core/controllers/item.php +++ b/core/controllers/item.php @@ -66,25 +66,40 @@ class Item_Controller extends Controller { switch ($this->input->post("type")) { case "album": - $new_item = album::create( + $album = album::create( $item->id, $this->input->post("name"), $this->input->post("title", $this->input->post("name")), $this->input->post("description")); + url::redirect("album/{$album->id}"); break; case "photo": - $new_item = photo::create( - $item->id, - $_FILES["file"]["tmp_name"], - $_FILES["file"]["name"], - $this->input->post("title", $this->input->post("name")), - $this->input->post("description")); + if (is_array($_FILES["file"]["name"])) { + for ($i = 0; $i < count($_FILES["file"]["name"]); $i++) { + if ($_FILES["file"]["error"][$i] == 0) { + $photo = photo::create( + $item->id, + $_FILES["file"]["tmp_name"][$i], + $_FILES["file"]["name"][$i], + $_FILES["file"]["name"][$i]); + } else { + print "ERROR!"; + // @todo return a reasonable error + } + } + url::redirect("album/{$item->id}"); + } else { + $photo = photo::create( + $item->id, + $_FILES["file"]["tmp_name"], + $_FILES["file"]["name"], + $this->input->post("title", $this->input->post("name")), + $this->input->post("description")); + url::redirect("{$new_item->type}/{$new_item->id}"); + } break; } - - print url::redirect("{$new_item->type}/{$new_item->id}"); - return; } public function delete($item) { -- cgit v1.2.3