summaryrefslogtreecommitdiff
path: root/core/controllers
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2008-11-10 12:28:58 +0000
committerBharat Mediratta <bharat@menalto.com>2008-11-10 12:28:58 +0000
commitceb07822339d92e399b3c93069ff356fcc68a278 (patch)
treef74ee5f31d807c2732c196a646a4ec91c3a48e4f /core/controllers
parentaceb0309731f94813eaefa9e34cd0253425c6151 (diff)
Add support for multi-file-upload using jquery.MultiFile and modify
Item_Controller to accept it.
Diffstat (limited to 'core/controllers')
-rw-r--r--core/controllers/item.php35
1 files changed, 25 insertions, 10 deletions
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) {