function attachment_view($attachment, $description, $mimetype) { switch (attachment_type($mimetype)) { case 'object video': case 'object audio': $view = "attachment/object"; break; case 'youtube video': $view = "attachment/youtube"; break; case 'vimeo video': $view = "attachment/vimeo"; break; case 'mp3 audio': $view = "attachment/mp3"; break; case 'image': $view = "attachment/image"; break; case 'download': case 'unknown': default: $view = "attachment/download"; } $ci = get_instance(); return $ci->load->view($view, array('attachment' => $attachment, 'description' => $description, 'mimetype' => $mimetype)); }
private function save_attachment($file) { $this->load->helper('attachment'); if (!is_array($file) || $file['error'] != 0) { return; } $type = attachment_type($file['type']); if (!isset($type)) { return; } $save_as = dirname($_SERVER['SCRIPT_FILENAME']) . "/attachments/{$type}/{$file['name']}"; if (!move_uploaded_file($file['tmp_name'], $save_as)) { die($file['tmp_name']); } return str_replace('//', '', '/' . str_replace($_SERVER['DOCUMENT_ROOT'], '', $save_as)); }