public static function setUnzipCommand($unzipCommand) { if (strpos($unzipCommand, '/src/') && strpos($unzipCommand, '/dst/')) { self::$unzipCommand = $unzipCommand; } }
foreach ($required_fields as $key => $value) { if (trim($value) == '') { $error = true; } } // if no errors, update the page if (!$error) { $p = $users->get("id={$page->id}"); $p->of(false); // turn off output formatting // tmp upload folder for additional security // possibly restrict access to this folder using htaccess: // # RewriteRule ^.tmp_uploads(.*) - [F] $upload_path = $config->paths->root . "tmp_uploads/"; // new wire upload $u = new WireUpload('uploads'); $u->setMaxFiles(1); $u->setOverwrite(true); $u->setDestinationPath($upload_path); $u->setValidExtensions(array('jpg', 'jpeg', 'gif', 'png')); // execute upload and check for errors $files = $u->execute(); if (!$u->getErrors()) { // add images upload foreach ($files as $filename) { $p->image = $upload_path . $filename; } $p->Name = $sanitizer->text($input->post->mitarbeitername); // Populate a field $p->Vorname = $sanitizer->text($input->post->mitarbeitervorname); // Populate a field
/** * Process a module upload * * @param string $inputName Optionally specify the name of the $_FILES input to look for (default=upload_module) * @param string $destinationDir Optionally specify destination path for completed unzipped files * @return bool|string Returns destinationDir on success, false on failure. * */ public function uploadModule($inputName = 'upload_module', $destinationDir = '') { if (!$this->canUploadDownload()) { $this->error($this->_('Unable to complete upload')); return false; } $tempDir = $this->getTempDir(); $ul = new WireUpload($inputName); $ul->setValidExtensions(array('zip')); $ul->setMaxFiles(1); $ul->setOverwrite(true); $ul->setDestinationPath($tempDir); $ul->setExtractArchives(false); $ul->setLowercase(false); $files = $ul->execute(); if (count($files)) { $file = $tempDir . reset($files); $destinationDir = $this->unzipModule($file, $destinationDir); if ($destinationDir) { $this->modules->resetCache(); } } else { $this->error($this->_('No uploads found')); $destinationDir = false; } return $destinationDir; }