/** * The upload handler. * * @param int $id The Proud id. * @return string The HTML code. */ public function upload($id = null) { $Proud = new Proud(); $Proud = $Proud->findItem(array('Id = ' . $id)); if (isset($_POST['upload'])) { $files = array('image' => new Proud_Image(), 'example' => new Proud_Example()); foreach ($files as $id => $class) { if (isset($_FILES[$id])) { foreach ($_FILES[$id]['name'] as $i => $value) { $file = File::convertMultiple($_FILES[$id], $i); if (empty($file['tmp_name'])) { continue; } $class->Id = null; $class->ProudId = $Proud->Id; if ($class->save()) { if (File::upload($class, $file)) { $class->save(); } else { if ($this->dropOnFailedUpload($class)) { $class->drop(); } } } } } } } return $this->getView()->htmlUpload($Proud); }