public function uploadAction() { global $Campsite; $auth = Zend_Auth::getInstance(); $userId = $auth->getIdentity(); $_FILES['file']['name'] = preg_replace('/[^\\w\\._]+/', '', $_FILES['file']['name']); $mimeType = $_FILES['file']['type']; $type = explode('/', $mimeType); if ($type[0] == 'image') { $file = Plupload::OnMultiFileUploadCustom($Campsite['IMAGE_DIRECTORY']); $image = Image::ProcessFile($_FILES['file']['name'], $_FILES['file']['name'], $userId, array('Source' => 'feedback', 'Status' => 'Unapproved', 'Date' => date('Y-m-d'))); $this->view->response = $image->getImageId(); } else { if ($type[1] == 'pdf') { $attachment = new Attachment(); $attachment->makeDirectories(); $file = Plupload::OnMultiFileUploadCustom($attachment->getStorageLocation()); $document = Attachment::ProcessFile($_FILES['file']['name'], $_FILES['file']['name'], $userId, array('Source' => 'feedback', 'Status' => 'Unapproved')); $this->view->response = $document->getAttachmentId(); } } }
camp_html_display_error(getGS('Invalid security token!')); exit; } if (!$g_user->hasPermission('AddFile')) { camp_html_display_error(getGS("You do not have the right to add files.")); exit; } $nrOfFiles = isset($_POST['uploader_count']) ? $_POST['uploader_count'] : 0; // process uploaded files for ($i = 0; $i < $nrOfFiles; $i++) { $tmpnameIdx = 'uploader_' . $i . '_tmpname'; $nameIdx = 'uploader_' . $i . '_name'; $statusIdx = 'uploader_' . $i . '_status'; if ($_POST[$statusIdx] == 'done') { $result = Attachment::ProcessFile($_POST[$tmpnameIdx], $_POST[$nameIdx], $g_user->getUserId()); } } if ($result != NULL) { camp_html_add_msg(getGS('"$1" files uploaded.', $nrOfFiles), "ok"); camp_html_goto_page("/$ADMIN/media-archive/multiedit_file.php"); } else { camp_html_add_msg($f_path . DIR_SEP . basename($newFilePath)); camp_html_goto_page($backLink); } ?>