/** * Displays the upload screen * @return void */ public function uploadAction() { //$this->_helper->layout->disableLayout(); $params = $this->getRequest()->getParams(); // gets the categories for upload + tagging $catDB = new Filfolders(); $this->view->categories = $catDB->getFoldersStructure(); if ($params['calledBy'] != 'adminpeople') { $this->setSubtitle('Upload files'); $this->setSideBar('upload', 'files'); } if (count($_FILES['file']) > 0) { switch ($_FILES['file']['error']) { case UPLOAD_ERR_OK: $fullpath = Sydney_Tools::getAppdataPath() . '/adminfiles/'; $filename = $_FILES['file']['name']; $ndirn = substr($filename, -3); $ndirn = preg_replace('/\\./', '', $ndirn); $nnd = $fullpath . '/' . strtoupper($ndirn); $type = strtoupper($ndirn); if (!is_dir($nnd)) { mkdir($nnd); } if (!empty($_POST['fileupload-new-filename'])) { $filename = $_POST['fileupload-new-filename']; } if (move_uploaded_file($_FILES['file']['tmp_name'], $nnd . '/' . $filename)) { $fil = new Filfiles(); $fil->registerFileToDb($nnd, $filename, filesize($nnd . '/' . $filename), $type, $this->usersId, $this->safinstancesId, $this->getRequest()); $returnmsg = '"' . $filename . '", ' . Sydney_Tools::_('UPLOAD_ERR_OK'); } else { $returnmsg = Sydney_Tools::_('UPLOAD_UNKNOW_ERROR'); } break; case UPLOAD_ERR_INI_SIZE: $returnmsg = Sydney_Tools::_('UPLOAD_ERR_INI_SIZE'); break; case UPLOAD_ERR_FORM_SIZE: $returnmsg = Sydney_Tools::_('UPLOAD_ERR_FORM_SIZE'); break; case UPLOAD_ERR_PARTIAL: $returnmsg = Sydney_Tools::_('UPLOAD_ERR_PARTIAL'); break; case UPLOAD_ERR_NO_FILE: $returnmsg = Sydney_Tools::_('UPLOAD_ERR_NO_FILE'); break; case UPLOAD_ERR_NO_TMP_DIR: $returnmsg = Sydney_Tools::_('UPLOAD_ERR_NO_TMP_DIR'); break; case UPLOAD_ERR_CANT_WRITE: $returnmsg = Sydney_Tools::_('UPLOAD_ERR_CANT_WRITE'); break; case UPLOAD_ERR_EXTENSION: $returnmsg = Sydney_Tools::_('UPLOAD_ERR_EXTENSION'); break; } if (!empty($returnmsg)) { echo '<span class="warning">', $returnmsg, '</span>'; } } }
/** * Moves all the files * * @param null $fullpath * @param $usersId * @param $safinstancesId * @param string $chunks * @param string $desc * @param string $returnType * @return array List of files or list of files ids */ public function moveAllChuncks($fullpath = null, $usersId, $safinstancesId, $chunks = 'chunks', $desc = '', $returnType = 'filenames') { // read the list of files $files = array(); if ($fullpath === null) { $fullpath = Sydney_Tools::getAppdataPath() . '/adminfiles/'; } if ($handle = opendir($fullpath . '/' . $chunks . '/')) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != ".." && $file != ".svn") { $files[] = $file; } } closedir($handle); } // do the process $fileIds = array(); foreach ($files as $filename) { $server = $this->_moveFileFromChunk($filename, $fullpath, $chunks); if (is_array($server)) { $fileIds[] = $this->registerFileToDb($server[0], $server[1], $server[2], $server[3], $usersId, $safinstancesId, array(), $desc); } } if ($returnType == 'filenames') { return $files; } elseif ($returnType == 'fileids') { return $fileIds; } elseif ($returnType == 'both') { return array($fileIds, $files); } }