public function process() { if (!empty($this->value['tmp_name']) && !empty($this->value['name'])) { $result = FileManager::MoveUpload($this->value['tmp_name'], $this->_directory . '/' . $this->value['name']); if (!FileManager::Error()) { $this->value = basename($result); } else { $this->error = 'Unable to upload ' . $this->label . ': ' . FileManager::Error(); } } else { $this->value = ''; } }
public function process() { if (!empty($this->value['tmp_name']) && !empty($this->value['name'])) { $result = basename(FileManager::GetPostedOrUploadedFile($this->_name, $this->_directory, 'jpg,jpeg,png,gif')); if (!FileManager::Error()) { $this->value = basename($result); } else { $this->error = 'Unable to upload ' . $this->label . ': ' . FileManager::Error(); } } else { $this->value = ''; } }
<?php $article->setArray($_POST, false); if (!empty($_POST['autosummary'])) { $article['autosummary'] = 1; $xml = Pagemill_SimpleXmlElement::LoadString($_POST['article']); if ($xml->p) { $summary = trim($xml->p[0]->innerXml()); } else { $summary = trim(Bam_Functions::GetIntro($_POST['article'])); } $article['summary'] = $summary; } else { $article['autosummary'] = 0; } $article['image'] = basename(FileManager::GetPostedOrUploadedFile('image', TYPEF_DIR . '/files/public/news', 'jpg,jpeg,png,gif')); if (FileManager::Error()) { $pm->addLoop('errors', array('message' => FileManager::Error())); } else { $article->save(); }
// process edit action if ('POST' == $_SERVER['REQUEST_METHOD']) { // get and validate name, if any $name = trim(@$_POST['categoryname']); if (strlen($name) > 0) { $category->set('categoryname', $name); } else { $errors[] = array('message' => 'Category name cannot be blank.'); } // get and validate image, if any if (@$_FILES['categoryimage']['tmp_name']) { $image = FileManager::MoveFile($_FILES['categoryimage']['tmp_name'], TYPEF_DIR . '/files/public/downloads/' . $_FILES['categoryimage']['name']); if ($image) { $image = basename($image); } else { $errors[] = array('message' => FileManager::Error()); } $category->set('categoryimage', $image); } $image = $category->get('categoryimage'); // get description, if any $description = trim(@$_POST['categorydescr']); $category->set('categorydescr', $description); // if no errors encountered above if (empty($errors)) { // save the changes if (Download_Category::MODE_ADD == $mode) { $category->add($name, $image, $description); } else { $category->save(); }